diff --git a/packages/eui/changelogs/upcoming/8047.md b/packages/eui/changelogs/upcoming/8047.md new file mode 100644 index 00000000000..724897c0114 --- /dev/null +++ b/packages/eui/changelogs/upcoming/8047.md @@ -0,0 +1,4 @@ +**Bug fixes** + +- Fixed `EuiSearchBox` skips input when running with React 18 in Legacy Mode + diff --git a/packages/eui/src/components/search_bar/search_box.tsx b/packages/eui/src/components/search_bar/search_box.tsx index 403e9840da3..2e935f622de 100644 --- a/packages/eui/src/components/search_bar/search_box.tsx +++ b/packages/eui/src/components/search_bar/search_box.tsx @@ -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'; @@ -39,7 +38,7 @@ export const EuiSearchBox: FunctionComponent = ({ }) => { const inputRef = useRef(null); - useUpdateEffect(() => { + useLayoutEffect(() => { if (inputRef.current) { inputRef.current.value = query; inputRef.current.dispatchEvent(new Event('change'));