Skip to content

Commit

Permalink
[ComboBox] Use isomorphic layout effect (#4018)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic McPhee authored and sylvhama committed Mar 26, 2021
1 parent c909219 commit 2e6d37f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Autocomplete/components/ComboBox/ComboBox.tsx
Expand Up @@ -8,6 +8,7 @@ import {Popover, PopoverProps} from '../../../Popover';
import {ActionListItemDescriptor, Key} from '../../../../types';
import {KeypressListener} from '../../../KeypressListener';
import {EventListener} from '../../../EventListener';
import {isServer} from '../../../../utilities/target';

import {ComboBoxContext} from './context';
import styles from './ComboBox.scss';
Expand Down Expand Up @@ -70,6 +71,8 @@ export function ComboBox({
setFalse: forcePopoverActiveFalse,
} = useToggle(false);

const useIsomorphicLayoutEffect = isServer ? useEffect : useLayoutEffect;

const id = useUniqueId('ComboBox', idProp);

const getActionsWithIds = useCallback(
Expand Down Expand Up @@ -240,7 +243,7 @@ export function ComboBox({
}
}, [selected, selectedOptions]);

useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
let newNavigableOptions: (
| OptionDescriptor
| ActionListItemDescriptor
Expand Down

0 comments on commit 2e6d37f

Please sign in to comment.