Skip to content

Commit

Permalink
fix: type error
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Aug 21, 2024
1 parent 9f5cbab commit 3fb8eac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/renderer/src/components/ui/input/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const TextArea = forwardRef<
[mouseX, mouseY],
)

const inputProps = useInputComposition(props)
const inputProps = useInputComposition<HTMLTextAreaElement>(props)
const [isFocus, setIsFocus] = useState(false)
return (
<div
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/src/hooks/common/useInputComposition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ export const useInputComposition = <E = HTMLInputElement>(

const isCompositionRef = useRef(false)

const handleCompositionStart: CompositionEventHandler<any> = useCallback(
const handleCompositionStart: CompositionEventHandler<E> = useCallback(
(e) => {
isCompositionRef.current = true
onCompositionStart?.(e)
onCompositionStart?.(e as any)
},
[onCompositionStart],
)

const handleCompositionEnd: CompositionEventHandler<any> = useCallback(
const handleCompositionEnd: CompositionEventHandler<E> = useCallback(
(e) => {
isCompositionRef.current = false
onCompositionEnd?.(e)
onCompositionEnd?.(e as any)
},
[onCompositionEnd],
)

const handleKeyDown: React.KeyboardEventHandler<any> = useCallback(
(e) => {
const handleKeyDown: React.KeyboardEventHandler<E> = useCallback(
(e: any) => {
// The keydown event stop emit when the composition is being entered
if (isCompositionRef.current) {
e.stopPropagation()
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/modules/panel/cmdf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const CmdFImpl: FC<{

const searchIdRef = useRef<number>(0)

const { isCompositionRef, ...inputProps } = useInputComposition({
const { isCompositionRef, ...inputProps } = useInputComposition<HTMLInputElement>({
onKeyDown: useEventCallback((e) => {
const $input = inputRef.current
if (!$input) return
Expand Down

0 comments on commit 3fb8eac

Please sign in to comment.