Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiSearchBox][React@18 Legacy Mode] useLayoutEffect in search_box #8047

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/eui/changelogs/upcoming/8047.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**Bug fixes**

- Fixed `EuiSearchBox` skips input when running with React 18 in Legacy Mode

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
Loading