Skip to content

Commit

Permalink
feat: remove portal call
Browse files Browse the repository at this point in the history
  • Loading branch information
florianstancioiu authored and cristinecula committed Apr 11, 2024
1 parent 21bf329 commit 8800c33
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions src/listbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
virtualizerRef,
} from '@lit-labs/virtualizer/virtualize.js';
import { sheet } from '@neovici/cosmoz-utils';
import { portal } from '@neovici/cosmoz-utils/directives/portal';
import { spreadProps } from '@neovici/cosmoz-utils/directives/spread-props';
import { useStyleSheet } from '@neovici/cosmoz-utils/hooks/use-stylesheet';
import { props } from '@neovici/cosmoz-utils/object';
Expand Down Expand Up @@ -56,9 +55,11 @@ const supportsPopover = () => {
const showPopover = (popover?: Element) => {
const popoverElement = popover as HTMLElement;

requestAnimationFrame(() => {
popoverElement?.showPopover();
});
if (supportsPopover()) {
requestAnimationFrame(() => {
popoverElement?.showPopover();
});
}
};

customElements.define(
Expand All @@ -70,21 +71,11 @@ export const listbox = <I>({
multi,
...thru
}: Props<I> & { multi?: boolean }) => {
if (supportsPopover()) {
return html`<cosmoz-listbox
${ref(showPopover)}
popover="manual"
part="listbox"
?multi=${multi}
...=${spreadProps(props(properties)(thru))}
></cosmoz-listbox>`;
}

return portal(
html`<cosmoz-listbox
part="listbox"
?multi=${multi}
...=${spreadProps(props(properties)(thru))}
></cosmoz-listbox>`,
);
return html`<cosmoz-listbox
${ref(showPopover)}
popover="manual"
part="listbox"
?multi=${multi}
...=${spreadProps(props(properties)(thru))}
></cosmoz-listbox>`;
};

0 comments on commit 8800c33

Please sign in to comment.