Skip to content

Commit

Permalink
fix: ignore first inputChange event, fix for #62
Browse files Browse the repository at this point in the history
  • Loading branch information
HADB committed Jul 24, 2024
1 parent dc822cb commit ae2eb16
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/easydict.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function (props: LaunchProps<{ arguments: EasydictArguments }>) {
const [isShowingDetail, setIsShowingDetail] = useState<boolean>(false);
const [isInstalledEudic, setIsInstalledEudic] = useState<boolean>(false);
const [isShowingReleasePrompt, setIsShowingReleasePrompt] = useState<boolean>(false);
const [isInputChanged, setInputChangedState] = useState<boolean>(false);

// check if need show release prompt, every time the list is rendered.
checkIfNeedShowReleasePrompt((isShowing) => {
Expand Down Expand Up @@ -232,6 +233,13 @@ export default function (props: LaunchProps<{ arguments: EasydictArguments }>) {

function onInputChange(text: string) {
// console.warn(`onInputChange: ${text}`);

// ignore the first inputChange event to avoid lost queryText argument
if (!isInputChanged) {
setInputChangedState(true);
console.warn("ignore first inputChange event");
return;
}
updateInputTextAndQueryText(text, true);
}

Expand Down

0 comments on commit ae2eb16

Please sign in to comment.