refactor: find in page (#7086)

- refactor rxjs data flow
- use canvas text to mitigate searchable search box input text issue
This commit is contained in:
pengx17
2024-05-28 06:19:53 +00:00
parent bd9c929d05
commit 2ca77d9170
12 changed files with 276 additions and 192 deletions
@@ -45,13 +45,21 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
autoFocus,
...otherProps
}: InputProps,
ref: ForwardedRef<HTMLInputElement>
upstreamRef: ForwardedRef<HTMLInputElement>
) {
const handleAutoFocus = useCallback((ref: HTMLInputElement | null) => {
if (ref) {
window.setTimeout(() => ref.focus(), 0);
}
}, []);
const handleAutoFocus = useCallback(
(ref: HTMLInputElement | null) => {
if (ref) {
window.setTimeout(() => ref.focus(), 0);
if (typeof upstreamRef === 'function') {
upstreamRef(ref);
} else if (upstreamRef) {
upstreamRef.current = ref;
}
}
},
[upstreamRef]
);
return (
<div
@@ -78,7 +86,7 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
large: size === 'large',
'extra-large': size === 'extraLarge',
})}
ref={autoFocus ? handleAutoFocus : ref}
ref={autoFocus ? handleAutoFocus : upstreamRef}
disabled={disabled}
style={inputStyle}
onChange={useCallback(