fix(geo): port schema select2 dropdown hooks - #522
Open
faisalahammad wants to merge 1 commit into
Open
Conversation
The GEO Schema.org Property and Output Format selects render through select2 (ui=1) but the dropdown panels render unstyled in SCF: upstream ACF 6.8.5 tags them with schema-property-select-results / schema-output-format-select-results / schema-type-select-results plus a 'Type to search...' placeholder via select2_args and select2_init hooks in assets/src/js/_acf-internal-post-type.js. SCF's copy of that file predates the schema code entirely. The CSS for those classes already ships via _admin-inputs.scss (WordPress#506), so porting the JS lights up the styled dropdown with no further CSS work. Adds a shared schemaSelect2Template, a select2_args filter that sets dropdownCssClass / templateResult / templateSelection / optgroup-aware matcher (property) and lock+disable (single-option output format), and a select2_init action that sets the search placeholder on select2:open. When the legacy select2 build drops dropdownCssClass via the compat check, the placeholder setter falls back to the open select2 container. Fixes WordPress#507
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the ACF 6.8.5 schema select2 hooks so the GEO Schema.org Property and Schema.org Output Format dropdowns render with the styled field-type-picker chrome instead of unstyled select2.
SCF renders both selects with select2 (
'ui' => 1) insrc/AI/GEO/FieldSettings.php, but the localassets/src/js/_acf-internal-post-type.jspredates the schema code, so the dropdown panels miss theschema-property-select-results/schema-output-format-select-results/schema-type-select-resultsclasses and the styled search input. SCF already has the SCSS for those classes viaassets/src/sass/_admin-inputs.scss(#506), so porting only the JS is enough to light up the styled dropdown.What is ported from ACF 6.8.5
_acf-internal-post-type.js:schemaSelect2TemplatefortemplateResult/templateSelectionselect2_argsfilter that setsargs.dropdownCssClassfor any select whosenameincludesschema_type,schema_property, orschema_output_formatargs.matcherforschema_propertyso typing matches parent group labels as well as child option textprop('disabled', true)forschema_output_formatwhen only one format is valid;acf.unlockplus anacf.isLockedguard on the way out so other locks (e.g. conditionals) still holdargs.allowReorder = falseforschema_typeselect2_initaction that onselect2:opensets the search input placeholder toType to search…for property and output format dropdowns, falling back to any open select2 container ifdropdownCssClasswas dropped by the$.fn.select2.amd.requirecompat checkCSS reference:
assets/src/sass/_admin-inputs.scss:999-1011declares the three schema-X-select-results selectors and@extends the.field-type-select-resultschrome that already shipped.Field-name sources it targets:
src/AI/GEO/FieldSettings.php:145(schema_property),src/AI/GEO/FieldSettings.php:169(schema_output_format),src/AI/GEO/GEO.php:97-98(schema_type). All three selects are picked up by the new filter.Closes #507
Use of AI Tools
AI tooling was used to assist with investigation, porting from upstream ACF 6.8.5, and PR preparation. Final code was reviewed and is held to the same standard as human-authored code.