wp-shortcake / shortcake

Shortcake makes using WordPress shortcodes a piece of cake.
GNU General Public License v2.0
664 stars 143 forks source link

Don't override global select2 z-indexing #749

Closed goldenapples closed 7 years ago

goldenapples commented 7 years ago

Because the select2 fields we're using here need to show up just over the absolutely positioned media modal, we're setting a z-index value of 16001, just above that modal.

However, there are other places in the WP admin (like the customizer) which require a much higher z-index value, so it would be better to target only the select2 instance which we're using.

This commit uses the "theme" argument to assign an additional classname to the select2 container, and then targets the container in CSS using the new classname.

Fixes #748

goldenapples commented 7 years ago

Oh, wait. I think there's a much less hacky way of doing this.

While investigating the select2 options to fix an unrelated bug, I came across the 'dropdownParent' parameter, which should make it possible for the dropdown to be attached to the media modal, in which case it can just be targetted with a child selector, like .edit-shortcode-form .select2-container.

I'll test and see if that works. If so, it seems better than this approach of passing multiple space-separated classes through a parameter that only expects a single slug and exploiting the fact that string concatenation is being used under the hood without any data validation.