summaryrefslogtreecommitdiff
path: root/extension/react-app/src
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-28 20:28:53 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-28 20:28:53 -0700
commit23167a51d959fed5e4be057ceb9fff50cf34c6c8 (patch)
tree2eed64df1fe2eeace81d5352230460272ff37526 /extension/react-app/src
parent58e5dc4a5c4fcbed25170b61fbd88d479c5aebcf (diff)
downloadsncontinue-23167a51d959fed5e4be057ceb9fff50cf34c6c8.tar.gz
sncontinue-23167a51d959fed5e4be057ceb9fff50cf34c6c8.tar.bz2
sncontinue-23167a51d959fed5e4be057ceb9fff50cf34c6c8.zip
fix: :children_crossing: clear the dropdown after text input cleared
Diffstat (limited to 'extension/react-app/src')
-rw-r--r--extension/react-app/src/components/ComboBox.tsx58
1 files changed, 34 insertions, 24 deletions
diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx
index 9aab4e93..da559383 100644
--- a/extension/react-app/src/components/ComboBox.tsx
+++ b/extension/react-app/src/components/ComboBox.tsx
@@ -162,33 +162,43 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
}
},
onInputValueChange({ inputValue, highlightedIndex }) {
- if (!inputValue) return;
+ if (!inputValue) {
+ setItems([]);
+ return;
+ }
props.onInputValueChange(inputValue);
if (inputValue.endsWith("@") || currentlyInContextQuery) {
- setCurrentlyInContextQuery(true);
-
const segs = inputValue.split("@");
- const providerAndQuery = segs[segs.length - 1];
- const [provider, query] = providerAndQuery.split(" ");
- searchClient
- .index(SEARCH_INDEX_NAME)
- .search(providerAndQuery)
- .then((res) => {
- setItems(
- res.hits.map((hit) => {
- return {
- name: hit.name,
- description: hit.description,
- id: hit.id,
- };
- })
- );
- })
- .catch(() => {
- // Swallow errors, because this simply is not supported on Windows at the moment
- });
- return;
+
+ if (segs.length > 1) {
+ // Get search results and return
+ setCurrentlyInContextQuery(true);
+ const providerAndQuery = segs[segs.length - 1];
+ const [provider, query] = providerAndQuery.split(" ");
+ searchClient
+ .index(SEARCH_INDEX_NAME)
+ .search(providerAndQuery)
+ .then((res) => {
+ setItems(
+ res.hits.map((hit) => {
+ return {
+ name: hit.name,
+ description: hit.description,
+ id: hit.id,
+ };
+ })
+ );
+ })
+ .catch(() => {
+ // Swallow errors, because this simply is not supported on Windows at the moment
+ });
+ return;
+ } else {
+ // Exit the '@' context menu
+ setCurrentlyInContextQuery(false);
+ setItems;
+ }
}
setItems(
props.items.filter((item) =>
@@ -262,7 +272,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
key={`${item.description.id.item_id}${idx}`}
item={item}
warning={
- false && item.content.length > 4000 && item.editing
+ item.content.length > 4000 && item.editing
? "Editing such a large range may be slow"
: undefined
}