Files
outline/app/scenes/Search/components/SearchInput.tsx
T
Tom MoorandClaude Opus 5 4b4c7d3281 chore: React 19 upgrade (#13562)
* React 19 upgrade

Bumps react and react-dom to 19.2.8, with the dependency changes React 19
requires: react-is 19, @types/react 19, @types/react-dom 19,
react-helmet-async 3 and react-avatar-editor 15 (which now ships its own
types). framer-motion moves to 13 — its v6 types reference React.ReactHTML,
removed from @types/react 19.

The type changes fall into a few classes:

- The global JSX namespace is gone, so JSX.Element becomes React.JSX.Element
  and the custom element declarations move into a module augmentation.
- useRef() now requires an initial value.
- A ref created with a null initial value is typed nullable, so consumers
  that accept one are widened to RefObject<T | null>.
- React.ReactChild was removed; tooltips take React.ReactNode.
- Ref callbacks may only return a cleanup function. react-dnd connectors
  return the connected node, so useDragRef and useDropRef wrap useDrag and
  useDrop and hand back a ref callback.

react-i18next stays on v12: i18next 23 drops compatibilityJSON "v3", which
would rewrite all 64 _plural keys across every locale.

outline-icons, oy-vey and react-waypoint have no release that lists React 19
as a peer. All three render correctly under it; the install reports them as
unmet peers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Remove react-helmet and forwardRef

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 22:22:50 -04:00

88 lines
2.0 KiB
TypeScript

import { SearchIcon } from "outline-icons";
import * as React from "react";
import styled, { useTheme } from "styled-components";
import { s } from "@shared/styles";
import Flex from "~/components/Flex";
interface Props extends React.InputHTMLAttributes<HTMLInputElement> {
name: string;
defaultValue: string;
ref: React.RefObject<HTMLInputElement | null>;
}
function SearchInput({ defaultValue, ref, ...rest }: Props) {
const theme = useTheme();
const focusInput = React.useCallback(() => {
ref.current?.focus();
}, [ref]);
React.useEffect(() => {
// ensure that focus is placed at end of input
const len = (defaultValue || "").length;
ref.current?.setSelectionRange(len, len);
const timeoutId = setTimeout(() => {
focusInput();
}, 100); // arbitrary number
return () => {
clearTimeout(timeoutId);
};
}, [ref, defaultValue, focusInput]);
return (
<Wrapper align="center">
<StyledIcon size={46} color={theme.placeholder} onClick={focusInput} />
<StyledInput
{...rest}
defaultValue={defaultValue}
ref={ref}
spellCheck="false"
type="search"
autoFocus
/>
</Wrapper>
);
}
const Wrapper = styled(Flex)`
position: relative;
margin-bottom: 8px;
`;
const StyledInput = styled.input`
width: 100%;
padding-block: 10px 10px;
padding-inline: 60px 10px;
font-size: 30px;
font-weight: 400;
outline: none;
border: 0;
background: ${s("inputBackground")};
border-radius: 4px;
color: ${s("text")};
::-webkit-search-cancel-button {
-webkit-appearance: none;
}
::-webkit-input-placeholder {
color: ${s("placeholder")};
}
:-moz-placeholder {
color: ${s("placeholder")};
}
::-moz-placeholder {
color: ${s("placeholder")};
}
:-ms-input-placeholder {
color: ${s("placeholder")};
}
`;
const StyledIcon = styled(SearchIcon)`
position: absolute;
inset-inline-start: 8px;
opacity: 0.7;
`;
export default SearchInput;