Files
outline/app/components/InputSearch.tsx
T
Tom MoorandClaude Fable 5 b17f2611bf chore: React 18 upgrade (#13559)
* React 18 upgrade

* fix: Force synchronous React rendering in server HTML export

React 18 can defer a legacy ReactDOM.render commit when sync work is
queued, leaving exported component nodes empty. Wrap the render in
flushSync, and flush unmount-scheduled passive effects before global
env cleanup so React never runs without a window.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: Move server ComponentView to createRoot

ReactDOM.render and unmountComponentAtNode are removed in React 19.
flushSync around root.render keeps the mount synchronous for the
HTML-export path, which reads the DOM immediately after.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Enable CI

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-03 01:43:47 -04:00

69 lines
1.7 KiB
TypeScript

import { SearchIcon } from "outline-icons";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { useTheme } from "styled-components";
import type { Props as InputProps } from "~/components/Input";
import Input from "~/components/Input";
type Props = InputProps & {
placeholder?: string;
value?: string;
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => unknown;
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => unknown;
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => unknown;
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => unknown;
};
function InputSearch(
props: Props,
ref: React.RefObject<HTMLInputElement | HTMLTextAreaElement>
) {
const { t } = useTranslation();
const theme = useTheme();
const [isFocused, setIsFocused] = React.useState(false);
const {
placeholder = `${t("Search")}…`,
onKeyDown,
onBlur,
onFocus,
...rest
} = props;
const handleFocus = React.useCallback(
(event: React.FocusEvent<HTMLInputElement>) => {
setIsFocused(true);
onFocus?.(event);
},
[onFocus]
);
const handleBlur = React.useCallback(
(event: React.FocusEvent<HTMLInputElement>) => {
setIsFocused(false);
onBlur?.(event);
},
[onBlur]
);
return (
<Input
type="search"
placeholder={placeholder}
icon={
<SearchIcon
color={isFocused ? theme.inputBorderFocused : theme.inputBorder}
/>
}
onKeyDown={onKeyDown}
onFocus={handleFocus}
onBlur={handleBlur}
margin={0}
labelHidden
ref={ref}
{...rest}
/>
);
}
export default React.forwardRef(InputSearch);