Skip to content

fix(geo): port schema select2 dropdown hooks - #522

Open
faisalahammad wants to merge 1 commit into
WordPress:trunkfrom
faisalahammad:fix/507-geo-schema-select2-classes
Open

fix(geo): port schema select2 dropdown hooks#522
faisalahammad wants to merge 1 commit into
WordPress:trunkfrom
faisalahammad:fix/507-geo-schema-select2-classes

Conversation

@faisalahammad

Copy link
Copy Markdown

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) in src/AI/GEO/FieldSettings.php, but the local assets/src/js/_acf-internal-post-type.js predates the schema code, so the dropdown panels miss the schema-property-select-results / schema-output-format-select-results / schema-type-select-results classes and the styled search input. SCF already has the SCSS for those classes via assets/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:

  • a shared schemaSelect2Template for templateResult / templateSelection
  • a select2_args filter that sets args.dropdownCssClass for any select whose name includes schema_type, schema_property, or schema_output_format
  • an optgroup-aware args.matcher for schema_property so typing matches parent group labels as well as child option text
  • lock + prop('disabled', true) for schema_output_format when only one format is valid; acf.unlock plus an acf.isLocked guard on the way out so other locks (e.g. conditionals) still hold
  • args.allowReorder = false for schema_type
  • a select2_init action that on select2:open sets the search input placeholder to Type to search… for property and output format dropdowns, falling back to any open select2 container if dropdownCssClass was dropped by the $.fn.select2.amd.require compat check

CSS reference: assets/src/sass/_admin-inputs.scss:999-1011 declares the three schema-X-select-results selectors and @extends the .field-type-select-results chrome 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.

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
@github-actions

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props faisalahammad, bernhard-reiter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port ACF's schema select2 dropdown JS so GEO pickers get the styled dropdown

1 participant