Repository navigation
[6.x] Find current chips' action menus when moving focus in element select inputs - #20659
Open
brandonkelly wants to merge 2 commits into
Open
brandonkelly wants to merge 2 commits into
brandonkelly wants to merge 2 commits into
Conversation
Chips render their actions as a craft-action-menu with a slot="invoker" button, so the .action-btn-only lookup found nothing, and focus was lost once an element select input became full. Amp-Thread-ID: https://ampcode.com/threads/T-0f39b248-dfd9-4abd-af51-991420229bc4 Co-authored-by: Amp <amp@ampcode.com>
[ci skip] Amp-Thread-ID: https://ampcode.com/threads/T-0f39b248-dfd9-4abd-af51-991420229bc4 Co-authored-by: Amp <amp@ampcode.com>
📚 Storybook previews@craftcms/ui — open Storybook No changed components detected in this Storybook. resources/js — open Storybook No changed components detected in this Storybook. |
This branch has not been deployed
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.
Description
Current chips render their actions as a
<craft-action-menu>with aslot="invoker"button. Only the deprecated disclosure-menu fallback still renders.btn.action-btn.getLastActionBtn()looked for.action-btnonly, so on current chips it found nothing, and once an element select input was full,getNextLogicalFocusElement()had no focus target.The same selector goes into both copies: core
BaseElementSelectInputand the Yii adapter'sCraft.BaseElementSelectInput, which still returns a jQuery collection (.find(…).last()).This also gives the selector modal its
triggerElementon a full field. #20652's container fallback fortriggerElementingetModalSettings()stays as a last resort for full fields with no chip action menu, such as whenshowActionMenuis off. Its test "gives a full field’s modal its container to return to" boots a full field whose chips get action menus, so with this change it gets the last chip's invoker instead of the container; that test's fixture needs chips without action menus (e.g.showActionMenu: false) once both land.Evidence
Unit tests: a full field's next focus target is the last chip's action menu invoker, in both copies.
expected null to be <craft-button …>(core),expected +0 to be 1(adapter)Browser: a server-rendered single-relation element select (limit 1, the UI kitchen sink's HTML renderer), choosing an entry with the keyboard:
document.activeElementis<body>.document.activeElementis the chip's<craft-button slot="invoker" aria-label="Actions">, with a visible focus ring.The workbench doesn't load the Yii adapter, so the adapter copy was checked through its jQuery unit test only.
Related issues