Skip to content

Commit

Permalink
chore: saving for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
geeky-abhishek committed May 6, 2022
1 parent 78aed75 commit 65f88c7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/search/search-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ export const SearchBar: FC<SearchBarProps> = ({

const onSearch = useCallback(() => {
updateQuery((currentQuery) => {
console.log('vvv currentQuery:', currentQuery);
console.log('vvv query:', query);
const ref = inputRef?.current;

if (ref) ref.innerText = '';
if (inputTyped.length > 0) {
console.log('vvv if-0');
const newInputState = [
...inputState,
...map(inputTyped?.split(' '), (item) => ({ label: item, hasAvatar: false }))
Expand All @@ -124,19 +127,27 @@ export const SearchBar: FC<SearchBarProps> = ({
)
);
}
console.log('vvv else');
console.log('vvv inputState:', inputState);
setInputTyped('');
// return inputState;
return reduce(
inputState,
(acc, chip) => {
console.log('mmm inputState:', inputState);
console.log('mmm chip:', chip);
console.log('mmm acc:', acc);
console.log('mmm currentQuery:', currentQuery);
if (!find(currentQuery, (c: QueryChip): boolean => c.label === chip.label)) {
acc.push(chip);
}
return acc;
},
// []
filter(
currentQuery,
(qchip: QueryChip): boolean =>
qchip.isQueryFilter ||
// qchip.isQueryFilter ||
!!find(inputState, (c: QueryChip): boolean => c.label === qchip.label)
)
);
Expand All @@ -146,7 +157,7 @@ export const SearchBar: FC<SearchBarProps> = ({
// }
setSearchIsEnabled(false);
// setChangedBySearchBar(true);
}, [updateQuery, inputTyped, inputState, history, module]);
}, [updateQuery, history, module, query, inputTyped, inputState]);

const appSuggestions = useMemo<Array<QueryChip & { hasAvatar: false }>>(
() =>
Expand Down Expand Up @@ -184,6 +195,7 @@ export const SearchBar: FC<SearchBarProps> = ({

const onQueryChange = useCallback(
(newQuery) => {
console.log('vv query:', newQuery);
if (
newQuery[newQuery.length - 1]?.label &&
module &&
Expand Down Expand Up @@ -214,7 +226,7 @@ export const SearchBar: FC<SearchBarProps> = ({
},
[appSuggestions, module, setStoredValue]
);

console.log('vvv nreQuery:', inputState);
const onInputType = useCallback(
(ev) => {
if (ev.target.textContent === '') {
Expand Down

0 comments on commit 65f88c7

Please sign in to comment.