Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0f30f62

Browse files
committedMay 22, 2025·
fix(scroll-assist): check for label instead
1 parent c49abb9 commit 0f30f62

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎core/src/utils/input-shims/hacks/scroll-assist.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,13 @@ const setManualFocus = (el: HTMLElement) => {
195195
* listener from incorrectly moving focus back to the input. That approach
196196
* would be less maintainable and more error-prone.
197197
*/
198-
if (document.activeElement?.parentNode === el.parentNode) {
198+
const inputId = el.getAttribute('id');
199+
const label = el.closest(`label[for="${inputId}"]`);
200+
const activeElLabel = document.activeElement?.closest(`label[for="${inputId}"]`);
201+
202+
if (label !== null && label === activeElLabel) {
203+
// If the label is the same as the active element label, then
204+
// we don't need to set the `SKIP_SCROLL_ASSIST` and reset focus.
199205
return;
200206
}
201207

0 commit comments

Comments
 (0)
Please sign in to comment.