Skip to content

Commit

Permalink
fix: remove duplicated search button on "search in chat"
Browse files Browse the repository at this point in the history
fixes #3014
  • Loading branch information
Simon-Laux committed Oct 13, 2023
1 parent 68f6d17 commit 7b85d61
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- add description for enableChatAuditLog setting
- fix: import key from file instead of folder, fixes #1863
- fix webxdc title not updated in document title changes #3412
- fix: remove duplicated search button on "search in chat" #3014

<a id="1_40_4"></a>

Expand Down
20 changes: 15 additions & 5 deletions src/renderer/components/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import { useTranslationFunction } from '../contexts'
export function ClearButton(props: {
onChange: (event: { target: { value: '' } }) => void
value: string
extraCleanAction?: () => void
}) {
const { onChange, value } = props
const onClear = () => onChange({ target: { value: '' } })
const { onChange, extraCleanAction, value } = props
const onClear = () => {
onChange({ target: { value: '' } })
extraCleanAction?.()
}

return (
<button
aria-label='Clear'
className={classNames(
'bp4-dialog-close-button bp4-button bp4-minimal bp4-icon-large bp4-icon-cross clear-button',
{ 'clear-button--hidden': value === '' }
{ 'clear-button--hidden': value === '' && !extraCleanAction }
)}
onClick={onClear}
/>
Expand All @@ -29,8 +33,10 @@ export default function SearchInput(props: {
className: string
id: string
inputRef?: React.ClassAttributes<HTMLInputElement>['ref']
/** if this is defined clear button is always shown, like with search in chat */
extraCleanAction?: () => void
}) {
const { onChange, value, className, id } = props
const { onChange, value, className, id, extraCleanAction } = props
const tx = useTranslationFunction()
return (
<>
Expand All @@ -44,7 +50,11 @@ export default function SearchInput(props: {
ref={props.inputRef}
spellCheck={false}
/>
<ClearButton value={value} onChange={onChange} />
<ClearButton
value={value}
onChange={onChange}
extraCleanAction={extraCleanAction}
/>
</>
)
}
4 changes: 2 additions & 2 deletions src/renderer/components/chat/ChatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ export default function ChatList(props: {
displayName={searchChatInfo.name}
/>
<div className='chat-name'>{searchChatInfo.name}</div>
<button
{/* <button
onClick={() => props.onExitSearch?.()}
aria-label={tx('exit_search')}
>
X
</button>
</button> */}
</div>
<div className='search-result-divider' style={{ width: width }}>
{translate_n('n_messages', messageResultIds.length)}
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/components/screens/MainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ export default function MainScreen() {
value={queryStr}
className='icon-rotated'
inputRef={searchRef}
extraCleanAction={
queryChatId ? () => setQueryChatId(null) : undefined
}
/>
)}
</NavbarGroup>
Expand Down

0 comments on commit 7b85d61

Please sign in to comment.