Skip to content

Commit

Permalink
useLayouEffect in search_box component
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant committed Sep 26, 2024
1 parent ebe9833 commit 71f530b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/eui/src/components/search_bar/search_box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
* Side Public License, v 1.
*/

import React, { FunctionComponent, useRef } from 'react';
import React, { FunctionComponent, useRef, useLayoutEffect } from 'react';

import { useUpdateEffect } from '../../services';
import { useEuiI18n } from '../i18n';
import { EuiFieldSearch, EuiFieldSearchProps } from '../form';
import { EuiInputPopover } from '../popover';
Expand Down Expand Up @@ -39,7 +38,7 @@ export const EuiSearchBox: FunctionComponent<EuiSearchBoxProps> = ({
}) => {
const inputRef = useRef<HTMLInputElement | null>(null);

useUpdateEffect(() => {
useLayoutEffect(() => {
if (inputRef.current) {
inputRef.current.value = query;
inputRef.current.dispatchEvent(new Event('change'));
Expand Down

0 comments on commit 71f530b

Please sign in to comment.