Skip to content

Commit f48255d

Browse files
vaadin-botweb-padawanclaude
authored
fix: prevent dashboard from losing focus on re-render in Firefox (#11659) (#11666)
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c97f42c commit f48255d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/dashboard/src/vaadin-dashboard.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ class Dashboard extends DashboardLayoutMixin(
263263
let wrappers = [...hostElement.children].filter((el) => el.localName === WRAPPER_LOCAL_NAME);
264264

265265
const focusedWrapper = wrappers.find((wrapper) => wrapper.querySelector(':focus'));
266+
const focusedElement = focusedWrapper && focusedWrapper.querySelector(':focus');
266267
const focusedWrapperWillBeRemoved = focusedWrapper && !this.__isActiveWrapper(focusedWrapper);
267268
const wrapperClosestToRemovedFocused =
268269
focusedWrapperWillBeRemoved && this.__getClosestActiveWrapper(focusedWrapper);
@@ -310,6 +311,10 @@ class Dashboard extends DashboardLayoutMixin(
310311
if (focusedWrapperWillBeRemoved) {
311312
// The wrapper containing the focused element was removed. Try to focus the element in the closest wrapper.
312313
this.__focusWrapperContent(wrapperClosestToRemovedFocused || this.querySelector(WRAPPER_LOCAL_NAME));
314+
} else if (focusedElement && !focusedElement.matches(':focus')) {
315+
// Firefox loses focus from a slotted element when the <slot> it was projected through is
316+
// removed during the shadow re-render, even after re-projection through a different slot.
317+
focusedElement.focus();
313318
}
314319

315320
const focusedItem = this.querySelector(':focus');

0 commit comments

Comments
 (0)