-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
can't input chinese #237
Comments
The same error occurs in the environment below. // ...
"next": "12.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
// ... Errors occur not only in Chinese, but also in CJK(Chines, Japanese, Korean )language, multi byte languages. This code is a simple correction to the error. // KBarSearch.tsx
import { useKBar, VisualState } from "kbar";
import React, { useState } from "react";
export const KBAR_LISTBOX = "kbar-listbox";
export const getListboxItemId = (id: number) => `kbar-listbox-item-${id}`;
export function KBarSearch(
props: React.InputHTMLAttributes<HTMLInputElement> & {
defaultPlaceholder?: string;
},
) {
const { query, searchQuery, actions, currentRootActionId, activeIndex, showing, options } =
useKBar(state => ({
searchQuery: state.searchQuery,
currentRootActionId: state.currentRootActionId,
actions: state.actions,
activeIndex: state.activeIndex,
showing: state.visualState === VisualState.showing,
}));
const [search, setSearch] = useState(searchQuery);
const ownRef = React.useRef<HTMLInputElement>(null);
const { defaultPlaceholder, ...rest } = props;
React.useEffect(() => {
query.setSearch("");
ownRef.current!.focus();
return () => query.setSearch("");
}, [currentRootActionId, query]);
React.useEffect(() => {
query.setSearch(search);
}, [query, search]);
const placeholder = React.useMemo((): string => {
const defaultText = defaultPlaceholder ?? "Type a command or search…";
return currentRootActionId && actions[currentRootActionId]
? actions[currentRootActionId].name
: defaultText;
}, [actions, currentRootActionId, defaultPlaceholder]);
return (
<input
{...rest}
ref={ownRef}
autoFocus
autoComplete="off"
role="combobox"
spellCheck="false"
aria-expanded={showing}
aria-controls={KBAR_LISTBOX}
aria-activedescendant={getListboxItemId(activeIndex)}
value={search}
placeholder={placeholder}
onChange={event => {
props.onChange?.(event);
setSearch(event.target.value);
options?.callbacks?.onQueryChange?.(event.target.value);
}}
onKeyDown={event => {
props.onKeyDown?.(event);
if (currentRootActionId && !search && event.key === "Backspace") {
const parent = actions[currentRootActionId].parent;
query.setCurrentRootAction(parent);
}
}}
/>
);
} |
Same with some icelandic letters, e.g. if I want to type á, then I first type ´ and then a to get á. For some reason this fails in kbar. The result will be: ´a |
Same issue with korean.
and this will work! // KBarSearch.tsx
import { useKBar, VisualState } from 'kbar';
import * as React from 'react';
export const KBAR_LISTBOX = 'kbar-listbox';
export const getListboxItemId = (id: number) => `kbar-listbox-item-${id}`;
export function KBarSearch(
props: React.InputHTMLAttributes<HTMLInputElement> & {
defaultPlaceholder?: string;
},
) {
const { query, searchQuery, actions, currentRootActionId, activeIndex, showing, options } =
useKBar((state) => ({
searchQuery: state.searchQuery,
currentRootActionId: state.currentRootActionId,
actions: state.actions,
activeIndex: state.activeIndex,
showing: state.visualState === VisualState.showing,
}));
const [search, setSearch] = React.useState(searchQuery);
const { defaultPlaceholder, ...rest } = props;
React.useEffect(() => {
query.setSearch('');
query.getInput().focus();
return () => query.setSearch('');
}, [currentRootActionId, query]);
React.useEffect(() => {
query.setSearch(search);
}, [query, search]);
const placeholder = React.useMemo((): string => {
const defaultText = defaultPlaceholder ?? 'Type a command or search…';
return currentRootActionId && actions[currentRootActionId]
? actions[currentRootActionId].name
: defaultText;
}, [actions, currentRootActionId, defaultPlaceholder]);
return (
<input
{...rest}
ref={query.inputRefSetter}
autoFocus
autoComplete="off"
role="combobox"
spellCheck="false"
aria-expanded={showing}
aria-controls={KBAR_LISTBOX}
aria-activedescendant={getListboxItemId(activeIndex)}
value={search}
placeholder={placeholder}
onChange={(event) => {
props.onChange?.(event);
setSearch(event.target.value);
options?.callbacks?.onQueryChange?.(event.target.value);
}}
onKeyDown={(event) => {
props.onKeyDown?.(event);
if (currentRootActionId && !search && event.key === 'Backspace') {
const parent = actions[currentRootActionId].parent;
query.setCurrentRootAction(parent);
}
}}
/>
);
} |
Hey! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
should auto remove the letters before the chinese I input.
2022-08-10.20.30.55.mov
The text was updated successfully, but these errors were encountered: