Skip to content

Commit a59ca68

Browse files
committed
fix: prevent dashboard from losing focus in Firefox
1 parent 43f8994 commit a59ca68

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
@@ -267,6 +267,7 @@ class Dashboard extends DashboardLayoutMixin(
267267
let wrappers = [...hostElement.children].filter((el) => el.localName === WRAPPER_LOCAL_NAME);
268268

269269
const focusedWrapper = wrappers.find((wrapper) => wrapper.querySelector(':focus'));
270+
const focusedElement = focusedWrapper && focusedWrapper.querySelector(':focus');
270271
const focusedWrapperWillBeRemoved = focusedWrapper && !this.__isActiveWrapper(focusedWrapper);
271272
const wrapperClosestToRemovedFocused =
272273
focusedWrapperWillBeRemoved && this.__getClosestActiveWrapper(focusedWrapper);
@@ -314,6 +315,10 @@ class Dashboard extends DashboardLayoutMixin(
314315
if (focusedWrapperWillBeRemoved) {
315316
// The wrapper containing the focused element was removed. Try to focus the element in the closest wrapper.
316317
this.__focusWrapperContent(wrapperClosestToRemovedFocused || this.querySelector(WRAPPER_LOCAL_NAME));
318+
} else if (focusedElement && !focusedElement.matches(':focus')) {
319+
// Firefox loses focus from a slotted element when the <slot> it was projected through is
320+
// removed during the shadow re-render, even after re-projection through a different slot.
321+
focusedElement.focus();
317322
}
318323

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

0 commit comments

Comments
 (0)