Skip to content

Commit

Permalink
DYN-6739 Regression Typing Fast in Search
Browse files Browse the repository at this point in the history
When typing fast in the TextSearch box was getting wrong results or the results were not in the same order than Dynamo InCanvasSearch,
It was happening due that we are implementing the React Debounce pattern (this patters allows the user to continue typing while we are searching ) but we were missing to update the results immediately after getting the results so I added a call to this.updateSearchViewDelayed() method immediately after getting the results.
  • Loading branch information
RobertGlobant20 committed Apr 22, 2024
1 parent 2028438 commit 20d3b73
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/LibraryContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class LibraryContainer extends React.Component<LibraryContainerProps, Lib
let hasText = text.length > 0;

if (hasText) {
// Starting searching immediately after user input,
// Starting searching immediately after user input,
// but only show change on ui after 300ms
setTimeout(function () {
if (this.props.libraryController.searchLibraryItemsHandler) {
Expand All @@ -274,6 +274,12 @@ export class LibraryContainer extends React.Component<LibraryContainerProps, Lib

// Set all categories and groups to be expanded
LibraryUtilities.setItemStateRecursive(this.generatedSectionsOnSearch, true, true);

//Due that we are using the React debouncing pattern that using the timeout we need to call the updateSearchViewDelayed() method immediately
//The updateSearchViewDelayed update the Library with the Search results got from callback (search engine results)
//If we don't call it here the call below will be executed firts without the results ready then will be showing wrong results.
this.updateSearchViewDelayed(text);

}.bind(this));
} else {
LibraryUtilities.searchItemResursive(this.generatedSections, text);
Expand Down

0 comments on commit 20d3b73

Please sign in to comment.