Fix: Prevent Multiple Search Icons in Command Menu (#10424)

Description:
This PR fixes an issue where clicking the search button multiple times
caused multiple search icons to appear in the search bar. The issue was
caused by continuously appending new items to the navigation stack
instead of replacing the existing search page entry.

Before:


https://github.com/user-attachments/assets/1abc4223-6295-4eea-b276-00e4539a2992



After:



https://github.com/user-attachments/assets/04d3a306-f3ca-4d3d-9028-9e4b4574e6a6

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
Rithik M
2025-03-03 20:38:34 +05:30
committed by GitHub
parent cb3b0633b5
commit 9300f0a29b

View File

@ -154,7 +154,11 @@ export const useCommandMenu = () => {
? []
: snapshot.getLoadable(commandMenuNavigationStackState).getValue();
if (resetNavigationStack) {
const itemIsAlreadyInStack = currentNavigationStack.some(
(item) => item.page === page,
);
if (resetNavigationStack || itemIsAlreadyInStack) {
set(commandMenuNavigationStackState, [{ page, pageTitle, pageIcon }]);
} else {
set(commandMenuNavigationStackState, [