-
Notifications
You must be signed in to change notification settings - Fork 839
Add search functionality to Independent Panel chat history #878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,6 +13,15 @@ function DeleteButton({ onConfirm, size, text }) { | |||||||||||||||||||||||||
const { t } = useTranslation() | ||||||||||||||||||||||||||
const [waitConfirm, setWaitConfirm] = useState(false) | ||||||||||||||||||||||||||
const confirmRef = useRef(null) | ||||||||||||||||||||||||||
const [confirming, setConfirming] = useState(false) | ||||||||||||||||||||||||||
const isMountedRef = useRef(true) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||
isMountedRef.current = true | ||||||||||||||||||||||||||
return () => { | ||||||||||||||||||||||||||
isMountedRef.current = false | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
}, []) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||
if (waitConfirm) confirmRef.current.focus() | ||||||||||||||||||||||||||
|
@@ -28,25 +37,53 @@ function DeleteButton({ onConfirm, size, text }) { | |||||||||||||||||||||||||
fontSize: '10px', | ||||||||||||||||||||||||||
...(waitConfirm ? {} : { display: 'none' }), | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
disabled={confirming} | ||||||||||||||||||||||||||
aria-busy={confirming ? 'true' : 'false'} | ||||||||||||||||||||||||||
aria-hidden={waitConfirm ? undefined : 'true'} | ||||||||||||||||||||||||||
tabIndex={waitConfirm ? 0 : -1} | ||||||||||||||||||||||||||
onMouseDown={(e) => { | ||||||||||||||||||||||||||
e.preventDefault() | ||||||||||||||||||||||||||
e.stopPropagation() | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
onBlur={() => { | ||||||||||||||||||||||||||
setWaitConfirm(false) | ||||||||||||||||||||||||||
if (!confirming && isMountedRef.current) setWaitConfirm(false) | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
onClick={() => { | ||||||||||||||||||||||||||
setWaitConfirm(false) | ||||||||||||||||||||||||||
onConfirm() | ||||||||||||||||||||||||||
onClick={async (e) => { | ||||||||||||||||||||||||||
if (confirming) return | ||||||||||||||||||||||||||
e.preventDefault() | ||||||||||||||||||||||||||
e.stopPropagation() | ||||||||||||||||||||||||||
setConfirming(true) | ||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||
await onConfirm() | ||||||||||||||||||||||||||
if (isMountedRef.current) setWaitConfirm(false) | ||||||||||||||||||||||||||
} catch (err) { | ||||||||||||||||||||||||||
// Keep confirmation visible to allow retry; optionally log | ||||||||||||||||||||||||||
// eslint-disable-next-line no-console | ||||||||||||||||||||||||||
console.error(err) | ||||||||||||||||||||||||||
} finally { | ||||||||||||||||||||||||||
if (isMountedRef.current) setConfirming(false) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
{t('Confirm')} | ||||||||||||||||||||||||||
</button> | ||||||||||||||||||||||||||
<span | ||||||||||||||||||||||||||
title={text} | ||||||||||||||||||||||||||
className="gpt-util-icon" | ||||||||||||||||||||||||||
style={waitConfirm ? { display: 'none' } : {}} | ||||||||||||||||||||||||||
onClick={() => { | ||||||||||||||||||||||||||
role="button" | ||||||||||||||||||||||||||
tabIndex={0} | ||||||||||||||||||||||||||
aria-label={text} | ||||||||||||||||||||||||||
aria-hidden={waitConfirm ? 'true' : undefined} | ||||||||||||||||||||||||||
style={waitConfirm ? { visibility: 'hidden' } : {}} | ||||||||||||||||||||||||||
onKeyDown={(e) => { | ||||||||||||||||||||||||||
Comment on lines
+73
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid aria-hidden on a focusable control
- role="button"
- tabIndex={0}
+ role="button"
+ tabIndex={waitConfirm ? -1 : 0}
aria-label={text}
- aria-hidden={waitConfirm ? 'true' : undefined}
- style={waitConfirm ? { visibility: 'hidden' } : {}}
+ aria-hidden={waitConfirm ? 'true' : undefined}
+ style={waitConfirm ? { visibility: 'hidden', pointerEvents: 'none' } : {}} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||
if (e.key === 'Enter' || e.key === ' ') { | ||||||||||||||||||||||||||
e.preventDefault() | ||||||||||||||||||||||||||
e.stopPropagation() | ||||||||||||||||||||||||||
setWaitConfirm(true) | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
onClick={(e) => { | ||||||||||||||||||||||||||
e.stopPropagation() | ||||||||||||||||||||||||||
setWaitConfirm(true) | ||||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.