* fix: #6301

* fix: update dependencies in useUpdateHandler and add eslint comment in ContentSearch
This commit is contained in:
自由的世界人 2025-05-22 21:24:40 +08:00 committed by GitHub
parent 72d939721d
commit 6f75b1738d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 8 deletions

View File

@ -399,6 +399,7 @@ export const ContentSearch = React.forwardRef<ContentSearchRef, Props>(
searchInputFocus() searchInputFocus()
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
const implementation = { const implementation = {
disable() { disable() {
setEnableContentSearch(false) setEnableContentSearch(false)
@ -526,8 +527,7 @@ export const ContentSearch = React.forwardRef<ContentSearchRef, Props>(
if (enableContentSearch && searchInputRef.current?.value.trim()) { if (enableContentSearch && searchInputRef.current?.value.trim()) {
implementation.search() implementation.search()
} }
// eslint-disable-next-line react-hooks/exhaustive-deps }, [isCaseSensitive, isWholeWord, enableContentSearch, implementation]) // Add enableContentSearch dependency
}, [isCaseSensitive, isWholeWord, enableContentSearch]) // Add enableContentSearch dependency
const prevButtonOnClick = () => { const prevButtonOnClick = () => {
implementation.searchPrev() implementation.searchPrev()
@ -690,18 +690,18 @@ const SearchResults = styled.div`
width: 80px; width: 80px;
margin: 0 2px; margin: 0 2px;
flex: 0 0 auto; flex: 0 0 auto;
color: var(--color-text-secondary); color: var(--color-text-1);
font-size: 14px; font-size: 14px;
font-family: Ubuntu; font-family: Ubuntu;
` `
const SearchResultsPlaceholder = styled.span` const SearchResultsPlaceholder = styled.span`
color: var(--color-text-secondary); color: var(--color-text-1);
opacity: 0.5; opacity: 0.5;
` `
const NoResults = styled.span` const NoResults = styled.span`
color: var(--color-text-secondary); color: var(--color-text-1);
` `
const SearchResultCount = styled.span` const SearchResultCount = styled.span`

View File

@ -85,5 +85,5 @@ export default function useUpdateHandler() {
}) })
] ]
return () => removers.forEach((remover) => remover()) return () => removers.forEach((remover) => remover())
}, [dispatch, t]) }, [dispatch, notificationService, t])
} }

View File

@ -434,7 +434,7 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
const text = textArea.value const text = textArea.value
let match = text.slice(cursorPosition + selectionLength).match(/\$\{[^}]+\}/) let match = text.slice(cursorPosition + selectionLength).match(/\$\{[^}]+\}/)
let startIndex = -1 let startIndex: number
if (!match) { if (!match) {
match = text.match(/\$\{[^}]+\}/) match = text.match(/\$\{[^}]+\}/)
@ -764,7 +764,12 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic, topic }) =
if (document.activeElement?.closest('.ant-modal')) { if (document.activeElement?.closest('.ant-modal')) {
return return
} }
textareaRef.current?.focus()
const lastFocusedComponent = PasteService.getLastFocusedComponent()
if (!lastFocusedComponent || lastFocusedComponent === 'inputbar') {
textareaRef.current?.focus()
}
} }
window.addEventListener('focus', onFocus) window.addEventListener('focus', onFocus)
return () => window.removeEventListener('focus', onFocus) return () => window.removeEventListener('focus', onFocus)