Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The module assumes the use of Drupal's core autocomplete widget. The active_tags.js
file has references to "#autocomplete
" div
ids and "input
" form elements. These items may not be present in replacement widgets.
The javascript code needs to be more generic by identifying the autocomplete field and using it as a reference throughout.
An updated patch will be posted shortly.
Comment | File | Size | Author |
---|---|---|---|
#16 | active_tags-non_core_autocomplete-2684609-16.patch | 2.84 KB | ron_s |
Comments
Comment #2
ron_s CreditAttribution: ron_s commentedAttached is a patch for review.
Comment #3
internal CreditAttribution: internal as a volunteer commentedWe also need this for enter key.
diff --git a/sites/all/modules/active_tags/active_tags.js b/sites/all/modules/ac
index ef7e215..0766c42 100644
--- a/sites/all/modules/active_tags/active_tags.js
+++ b/sites/all/modules/active_tags/active_tags.js
@@ -33,7 +33,7 @@ activeTags.checkEnter = function (event) {
$('#autocomplete').each(function () {
this.owner.hidePopup();
});
- $(this).parent().find('.at-add-btn').click();
+ $('.at-add-btn').click();
event.preventDefault();
return false;
}
Comment #4
internal CreditAttribution: internal as a volunteer commentedOverall, the function calls like $(this).parent().find in js are not safe in different themes. By now we just encounter then fix.
Comment #5
ron_s CreditAttribution: ron_s commentedI don't believe your suggestion in #3 will work correctly on forms that have multiple Active Tags.
Comment #6
ron_s CreditAttribution: ron_s commentedI disagree with your statement in #4. There is no problem with
$(this).parent().find
. The issue has to do with#autocomplete
vs..dropdown
. That is what's causing the problem.Comment #7
internal CreditAttribution: internal as a volunteer commentedThat's fine. #3 is not a general patch. But I have to use it for the enter key for me. #2 works.
Comment #8
ron_s CreditAttribution: ron_s commented@internal, I'm going to create a clean patch. You can use what you have in #3 if you like, but it will eventually need to be replaced.
Comment #9
internal CreditAttribution: internal as a volunteer commentedThanks, @ron_s. I'm also trying to improve it. Here's something about the enter key and wrong hidePopup.
https://www.drupal.org/node/309088
Comment #10
ron_s CreditAttribution: ron_s commentedI have a working solution, but needs to be tested more. Setting this as "needs work" until I can post it.
Comment #11
ron_s CreditAttribution: ron_s commentedComment #12
ron_s CreditAttribution: ron_s commentedComment #13
ron_s CreditAttribution: ron_s commentedPlease review the attached patch.
I'd also recommend reviewing the patch here: https://www.drupal.org/node/2685299, since this is necessary to support multiple Active Tags-enabled fields on a form.
Comment #14
internal CreditAttribution: internal as a volunteer commentedTested #13. There is a bug with and without the patch.
Steps:
Type 'a' in autocomplete text field.
If you have 'apple' or 'bad' items in dropdown list, use arrow key to select apple, press enter key.
Bug: The 'a' is added as a new tag first, next enter key adds 'apple' tag.
It seems the first enter key should not be sent to the text field but the dropdown list.
Comment #15
ron_s CreditAttribution: ron_s commentedSomething must have happened with the patch, because this was working correctly before. I'll have to take a look at it.
Comment #16
ron_s CreditAttribution: ron_s commentedNew version of the patch. When using the keyboard, the
.closest
function would not work as coded because it is one level deeper.This update definitely works, although I do have some concern because it relies on the
.form-wrapper
class. If a theme strips this class, it's not going to work... however I'm not sure how else the field ID can be accurately captured for all use cases without using it. I've added a "@todo
" in the code in case this comes up in the future.Also there is a new version of this patch that you should update: https://www.drupal.org/node/2685299
Comment #17
internal CreditAttribution: internal as a volunteer commentedPatch #16 works great, thank you very much! Pretty cool module again. Remember to apply that patch first from https://www.drupal.org/node/2626802 if your theme requires jQuery 1.9+.
Comment #18
ron_s CreditAttribution: ron_s commentedDon't you mean patch #16? Patch #13 was the old one you said didn't work.
Comment #19
internal CreditAttribution: internal as a volunteer commentedEdited. Too happy to watch;)