fix(ui5-li): prevent item-click for disabled nested interactive controls#13275
Open
plamenivanov91 wants to merge 3 commits intomainfrom
Open
fix(ui5-li): prevent item-click for disabled nested interactive controls#13275plamenivanov91 wants to merge 3 commits intomainfrom
plamenivanov91 wants to merge 3 commits intomainfrom
Conversation
Previously, `_onclick` in `ListItemBase` suppressed the `_press` event by checking `:has(:focus-within)` on the focus DOM ref. This approach is fragile: if a nested interactive element (e.g. a button) disables itself synchronously during its own `click` handler, focus is lost before the event bubbles up to the list item. As a result, the `:focus-within` check fails and `ui5-item-click` fires unexpectedly ? a regression observed in Chrome since v2.4.0. Replace the focus-based guard with an event-path inspection: `_isInteractiveContentClicked` walks `e.composedPath()` from the clicked target up to (but not including) the list item boundary and returns `true` if any element matches a native or UI5 interactive control. This correctly suppresses `item-click` regardless of whether the inner element changes its disabled/focused state during the click. Add a regression test: nested `ui5-button` that disables itself on click must not trigger `ui5-item-click` on the parent list item. Fixes: #10976
Collaborator
|
🚀 Deployed on https://pr-13275--ui5-webcomponents-preview.netlify.app |
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.
Previously, ListItemBase relied only on a focus-within check in onclick to suppress item press when interactive content was clicked. In Chrome, this is fragile when a nested control disables itself synchronously in its own click handler, because focus can be lost before list item click handling runs, causing ui5-item-click to fire unexpectedly.
The fix keeps the existing focus-within behavior and adds a fallback check over e.composedPath() for disabled interactive targets. Instead of hardcoded ui5-* tag lists, the fallback now uses a duck-typed approach. It handles native interactive controls (button, input, select, textarea) and custom interactive elements identified by custom-element semantics plus disabled or aria-disabled support. Disabled state is resolved via disabled property or aria-disabled="true".
This keeps behavior unchanged for normal focus-driven cases while covering the disable-on-click timing scenario with a more maintainable implementation.
Regression coverage now includes nested ui5-button that disables itself on click and must not fire ui5-item-click, nested disabled custom element that must not fire ui5-item-click, nested enabled custom element that should still fire ui5-item-click, and nested ui5-link behavior that is explicitly covered.
Fixes: #10976