mirror of
https://github.com/stablyai/orca.git
synced 2026-10-16 00:03:09 +00:00
perf: clean settings search reset from effect
This commit is contained in:
@@ -213,6 +213,18 @@ function Settings(): React.JSX.Element {
|
||||
const repoHooksRuntimeIdentityRef = useRef<string>('local')
|
||||
const shortcutsEscapeConfirmUntilRef = useRef(0)
|
||||
|
||||
const setSettingsRootNode = useCallback(
|
||||
(node: HTMLDivElement | null): void => {
|
||||
if (node) {
|
||||
return
|
||||
}
|
||||
// Why: the settings search is a transient in-page filter. Leaving it behind makes the next
|
||||
// visit look partially broken because whole sections stay hidden before the user types again.
|
||||
setSettingsSearchQuery('')
|
||||
},
|
||||
[setSettingsSearchQuery]
|
||||
)
|
||||
|
||||
const confirmDiscardCommitPromptChanges = useCallback(async (): Promise<boolean> => {
|
||||
if (!hasUnsavedCommitPromptChanges) {
|
||||
return true
|
||||
@@ -339,15 +351,6 @@ function Settings(): React.JSX.Element {
|
||||
return () => document.removeEventListener('keydown', handleFindShortcut)
|
||||
}, [keybindings])
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
// Why: the settings search is a transient in-page filter. Leaving it behind makes the next
|
||||
// visit look partially broken because whole sections stay hidden before the user types again.
|
||||
setSettingsSearchQuery('')
|
||||
},
|
||||
[setSettingsSearchQuery]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!settings || !settingsNavigationTarget) {
|
||||
return
|
||||
@@ -694,8 +697,13 @@ function Settings(): React.JSX.Element {
|
||||
|
||||
if (!settings) {
|
||||
return (
|
||||
<div className="flex flex-1 items-center justify-center text-muted-foreground">
|
||||
Loading settings...
|
||||
<div
|
||||
ref={setSettingsRootNode}
|
||||
className="settings-view-shell flex min-h-0 flex-1 overflow-hidden bg-background"
|
||||
>
|
||||
<div className="flex flex-1 items-center justify-center text-muted-foreground">
|
||||
Loading settings...
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -721,7 +729,10 @@ function Settings(): React.JSX.Element {
|
||||
activeSectionId === 'shortcuts' && settingsSearchQuery.trim() === ''
|
||||
|
||||
return (
|
||||
<div className="settings-view-shell flex min-h-0 flex-1 overflow-hidden bg-background">
|
||||
<div
|
||||
ref={setSettingsRootNode}
|
||||
className="settings-view-shell flex min-h-0 flex-1 overflow-hidden bg-background"
|
||||
>
|
||||
<SettingsSidebar
|
||||
activeSectionId={activeSectionId}
|
||||
generalGroups={generalNavGroups}
|
||||
|
||||
Reference in New Issue
Block a user