Skip to content

Commit 22e9d39

Browse files
committed
fix: ssr issue
1 parent b034fcf commit 22e9d39

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

core/pfe-core/controllers/combobox-controller.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { nothing, type ReactiveController, type ReactiveControllerHost } from 'lit';
1+
import { isServer, nothing, type ReactiveController, type ReactiveControllerHost } from 'lit';
22
import type { ActivedescendantControllerOptions } from './activedescendant-controller.js';
33
import type { RovingTabindexControllerOptions } from './roving-tabindex-controller.js';
44
import type { ATFocusController } from './at-focus-controller';
@@ -211,15 +211,17 @@ export class ComboboxController<
211211

212212
// Hide listbox on focusout
213213
static {
214-
document.addEventListener('focusout', event => {
215-
const target = event.target as HTMLElement;
216-
for (const host of ComboboxController.hosts) {
217-
if (host instanceof Node && host.contains(target)) {
218-
const instance = ComboboxController.instances.get(host);
219-
instance?._onFocusoutElement();
214+
if (!isServer) {
215+
document.addEventListener('focusout', event => {
216+
const target = event.target as HTMLElement;
217+
for (const host of ComboboxController.hosts) {
218+
if (host instanceof Node && host.contains(target)) {
219+
const instance = ComboboxController.instances.get(host);
220+
instance?._onFocusoutElement();
221+
}
220222
}
221-
}
222-
});
223+
});
224+
}
223225
}
224226

225227
private options: RequireProps<ComboboxControllerOptions<Item>,

0 commit comments

Comments
 (0)