Skip to content

Commit

Permalink
fix(combobox): combobox should close after pressing tab on an executa…
Browse files Browse the repository at this point in the history
…ble command
  • Loading branch information
MarcMcIntosh committed Apr 9, 2024
1 parent 0a14e77 commit 5b320e9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ export const ComboBox: React.FC<ComboBoxProps> = ({
defaultActiveId: undefined,
});

// TODO: uninstall this package
// const matches = matchSorter(commandsOrArguments, trigger, {
// baseSort: (a, b) => (a.index < b.index ? -1 : 1),
// threshold: 0,
// });

const matches = commandsOrArguments;

const hasMatches = !!trigger && !!matches.length;
Expand Down Expand Up @@ -198,11 +192,23 @@ export const ComboBox: React.FC<ComboBoxProps> = ({
startPosition,
);

setTrigger(command);
onChange(newInput.value);
setEndPosition(newInput.endPosition);
setSelectedCommand(selectedCommand ? "" : command);

combobox.setValue(command);
if (selectedCommand) {
setSelectedCommand("");
setTrigger(command);
setStartPosition(null);
// onChange(newInput.value + "\n");
// setEndPosition(newInput.endPosition + 1);
combobox.hide();
} else {
setSelectedCommand(command);
setTrigger(command);
// onChange(newInput.value);
// setEndPosition(newInput.endPosition);
}
}

if (event.key === "Space" && state.open && commands.includes(trigger)) {
Expand Down

0 comments on commit 5b320e9

Please sign in to comment.