Closed (fixed)
Project:
Chosen
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Mar 2016 at 14:53 UTC
Updated:
14 Apr 2016 at 08:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jhedstromThis patch depends on #2696483: Remove redundant 'chosen_' prefix to all settings, so won't apply automatically or won't pass tests until that is committed.
Because of the option to use chosen globally (which is typically how I've used this module in the past), the library must be added for every select element. Because of the ability to attach libraries and settings to an element in D8 though, we can as suggested above, remove the global
hook_page_attachments(), and only attach the library on pages that have a select element.Comment #4
jhedstromNew patch since the previous one had missed the change to
chosen_disabled_themes.Comment #6
nagy.balint commentedComment #7
nagy.balint commentedCant we use some static cache, and if this code already ran once we don't need to run it again?
Because it will just add the same attachment and the same drupalSettings anyways.
Otherwise the patch seems to be fine.
Comment #8
jhedstromWe could, but the core
AttachedAssetsservice ensures a library isn't added more than once.Comment #9
jhedstromAnd actually, now that I'm thinking about it more, using a static could be dangerous here since render arrays may be cached, and if we don't attach the library to each instance that needs it, there could be a situation where the library doesn't properly get loaded.
Comment #10
ademarco commentedPatch #4 worked very well for me, thanks! Marking as RTBC.
Comment #12
nagy.balint commentedThanks!