Preserve search input and focus when toggling browse mode

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-22 23:25:40 +01:00
parent 6336dec38a
commit 64741956dd

View File

@@ -493,8 +493,17 @@ export function ActionBar({
};
const toggleBrowseMode = () => {
setBrowseMode((m) => !m);
clearInput();
setBrowseMode((prev) => {
const next = !prev;
setSuggestionIndex(-1);
setQueued(null);
if (next) {
handleBrowseSearch(nameInput);
} else {
handleAddSearch(nameInput);
}
return next;
});
clearCustomFields();
};
@@ -555,6 +564,7 @@ export function ActionBar({
"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-hover-neutral",
browseMode && "text-accent",
)}
onMouseDown={(e) => e.preventDefault()}
onClick={toggleBrowseMode}
title={browseMode ? "Switch to add mode" : "Browse stat blocks"}
aria-label={