Skip to content

Additional in form field type selection and reusable layout+script - #141

Draft
LadySolveig wants to merge 3 commits into
bembelimen:6.2/custom-field-selectfrom
LadySolveig:6.2/enhancement/fieldtypeselect
Draft

Additional in form field type selection and reusable layout+script#141
LadySolveig wants to merge 3 commits into
bembelimen:6.2/custom-field-selectfrom
LadySolveig:6.2/enhancement/fieldtypeselect

Conversation

@LadySolveig

@LadySolveig LadySolveig commented Jul 25, 2026

Copy link
Copy Markdown

Summary

#48137 implemented custom-field type selection by cloning com_modules' "New Module" screen. A separate full-page gallery with its own copy-pasted search, and deprecated the inline TypeField, so a field's type could no longer be changed on the edit form.

This PR reworks that into two reusable primitives and wires com_fields through them:

  1. A shared selection-gallery layout (layouts/joomla/selectiongallery/default.php). One searchable card grid, rendered full-page or cloned into a dialog.
  2. An inline mode on joomla-field-modal-select. Opens the gallery in a JoomlaDialog (popupType: 'inline', same document, no postMessage), reusing Joomla's existing batch-dialog pattern.

Benefits

Maintenance

  • Deletes the one duplicated search script (admin-field-select-search.es6.js, a copy of com_modules') and the bespoke com_fields gallery markup. Both replaced by one shared layout + one shared search asset.
  • admin-field-typehaschanged goes from a deprecated, inline-invoked global to a self-wiring listener. One clear owner of the reload behaviour.
  • The picker is encapsulated in the field, so tmpl/field/edit.php collapses to $this->form->getInput('type') and the view no longer prepares any type data.
  • One place to fix gallery a11y/keyboard/dialog behaviour instead of a com_fields-specific copy.

UX / layout deduplication

  • The same shared gallery renders both the full-page create screen and the inline change-type picker — one card grid, search, empty-state, and grouping, no com_fields-specific variant to drift.
  • One opt-in selectMode flag switches the shared cards between full-page navigation (<a href>) and inline selection (<button>), so there's no forked markup.
  • For a new (unsaved) field you can fix a wrong type inline on the edit form instead of going back to the select screen. The type is still locked once the field is saved.

Reusable beyond com_fields (examples, not changed here)

  • com_modules "New Module" gallery can migrate to the shared layout + generic search the same way (follow-on, its legacy data-function editor-insert path needs separate care).
  • #47676 — the proposed (unmerged) joomla-field-modal-select PR: its module-position picker adopts the identical content attribute + a positions <template>; grouped positions are already handled by the shared layout/search.
  • Web Component reference: Manual PR #619

Before → after (this feature only)

Aspect Initial implementation (joomla#48137 as landed) New implementation (this PR)
Type selection UI Full-page "select type" screen only; type can't be chosen/changed on the form Same shared gallery powers both. The full-page create screen (links) and a new inline "Change type" picker on the edit form (iframe-free dialog, buttons)
Gallery markup Bespoke cards duplicated in com_fields Shared selectiongallery layout
Search admin-field-select-search.es6.js (near-verbatim copy of com_modules') Deleted; replaced by one generic selectiongallery-search asset
TypeField Deprecated; type fixed before the form loads Un-deprecated; encapsulates the picker via a layout
Type-change reload admin-field-typehaschanged deprecated Rewritten + un-deprecated: self-binding change listener, no inline onchange="" (CSP-friendly)
Changing a new field's type Fixed once you're on the form — to pick differently you return to the select screen Correct it inline on the edit form. After the first save the type is locked in both (enforced by FieldModel::preprocessForm())
Gallery accessibility Search gives no screen-reader feedback. Live-region search status.

Accessibility (WCAG 2.1 AA)

Fixed in the shared gallery (issues inherited from the com_modules copy):

  • Live-search results announced via role="status" aria-live="polite". Search before gave no screen-reader feedback.

Built into the new inline picker (a new surface — correctness by design, not a fix):

  • The current type is exposed as a labelled role="group" ("Field Type: Text").
  • Selection cards are real <button>s (native Enter/Space, no role="button"); full-page cards stay real <a href> links. Autofocus is scoped to the dialog.

Security

  • No inline event handler on the type field, one fewer obstacle to a strict CSP.

- Introduced a new `joomla-field-modal-select` web component for inline modal selection of field types.
- Replaced the previous search functionality with a unified `selectiongallery-search` script for live filtering of field types.
- Updated `TypeField` to render the new modal select component and handle field type changes more efficiently.
@LadySolveig LadySolveig changed the title Refactor field type selection to use a modal component Additional field type selection with modal component Jul 25, 2026
@LadySolveig LadySolveig changed the title Additional field type selection with modal component Additional in form field type selection and reusable layout+script Jul 25, 2026
@LadySolveig

LadySolveig commented Jul 26, 2026

Copy link
Copy Markdown
Author

@dgrammatiko is it worth introducing a web component and the reusable/shared layout, or is it a bit over-engineered?
I’d be interested to hear your opinion.

@dgrammatiko

Copy link
Copy Markdown

I’m not a big fan of light dom custom elements, I prefer real web components (slots, shadow dom, element internals etc)…

@LadySolveig

LadySolveig commented Jul 26, 2026

Copy link
Copy Markdown
Author

For me, the question was more whether we actually want something in a more centralized way. The original PR simply duplicates and adjusts the search script and view from modules and removes the option to change it in the form. Not sure which would be here the preferred approach, so I thought about an alternative.

@dgrammatiko

Copy link
Copy Markdown

In that sense yes DRY is better, the implementation though…

@LadySolveig

Copy link
Copy Markdown
Author

Thanks for your feedback. I’d already realised you weren’t a big fan of the implementation so far. :D I’ll wait and see if there’s any interest at all.

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.

2 participants