Additional in form field type selection and reusable layout+script - #141
Additional in form field type selection and reusable layout+script#141LadySolveig wants to merge 3 commits into
Conversation
- 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.
|
@dgrammatiko is it worth introducing a web component and the reusable/shared layout, or is it a bit over-engineered? |
|
I’m not a big fan of light dom custom elements, I prefer real web components (slots, shadow dom, element internals etc)… |
|
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. |
|
In that sense yes DRY is better, the implementation though… |
|
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. |
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:
layouts/joomla/selectiongallery/default.php). One searchable card grid, rendered full-page or cloned into a dialog.joomla-field-modal-select. Opens the gallery in aJoomlaDialog(popupType: 'inline', same document, nopostMessage), reusing Joomla's existing batch-dialog pattern.Benefits
Maintenance
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-typehaschangedgoes from a deprecated, inline-invoked global to a self-wiring listener. One clear owner of the reload behaviour.tmpl/field/edit.phpcollapses to$this->form->getInput('type')and the view no longer prepares any type data.UX / layout deduplication
selectModeflag switches the shared cards between full-page navigation (<a href>) and inline selection (<button>), so there's no forked markup.Reusable beyond com_fields (examples, not changed here)
data-functioneditor-insert path needs separate care).joomla-field-modal-selectPR: its module-position picker adopts the identicalcontentattribute + a positions<template>; grouped positions are already handled by the shared layout/search.Before → after (this feature only)
selectiongallerylayoutadmin-field-select-search.es6.js(near-verbatim copy of com_modules')selectiongallery-searchassetTypeFieldadmin-field-typehaschangeddeprecatedchangelistener, no inlineonchange=""(CSP-friendly)FieldModel::preprocessForm())Accessibility (WCAG 2.1 AA)
Fixed in the shared gallery (issues inherited from the com_modules copy):
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):
role="group"("Field Type: Text").<button>s (native Enter/Space, norole="button"); full-page cards stay real<a href>links. Autofocus is scoped to the dialog.Security