Skip to content

Commit

Permalink
fix: ignore first inputChange event, fix for #62 (#63)
Browse files Browse the repository at this point in the history
* fix: ignore first inputChange event, fix for #62

* chore: change console.warn to console.log

* style: add comment

---------

Co-authored-by: tisfeng <[email protected]>
  • Loading branch information
HADB and tisfeng authored Jul 24, 2024
1 parent dc822cb commit 3d3fa96
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, fix https://github.com/tisfeng/Raycast-Easydict/issues/62
if (!isInputChanged) {
setInputChangedState(true);
console.log("ignore first inputChange event");
return;
}
updateInputTextAndQueryText(text, true);
}

Expand Down

0 comments on commit 3d3fa96

Please sign in to comment.