(null)
const [visibilityTarget, setVisibilityTarget] = useState<{ namespace: string; slug: string; visibility: string } | null>(null)
const scrollKey = JSON.stringify([user?.userId, keyword, namespaceFilter, filter, page])
const [archiveTarget, setArchiveTarget] = useState<{ namespace: string; slug: string; name: string } | null>(null)
@@ -124,9 +126,29 @@ export function MySkillsPage() {
return () => cancelAnimationFrame(frame)
}, [isLoading, scrollKey])
+ // Query invalidation can remove the row after its confirmation has already closed.
+ useEffect(() => {
+ const trigger = restoredTrigger.current
+ if (!trigger) return
+ const active = document.activeElement
+ if (!trigger.isConnected) {
+ if (active === document.body) searchInput.current?.focus()
+ restoredTrigger.current = null
+ } else if (active !== trigger && active !== document.body) {
+ restoredTrigger.current = null
+ }
+ }, [skillPage?.items])
+
const restoreMoreFocus = (event: Event) => {
event.preventDefault()
- compareTrigger.current?.focus()
+ const trigger = compareTrigger.current
+ if (trigger?.isConnected) {
+ restoredTrigger.current = trigger
+ trigger.focus()
+ } else {
+ restoredTrigger.current = null
+ searchInput.current?.focus()
+ }
}
const handleSkillClick = (namespace: string, slug: string, version?: string) => {
@@ -340,6 +362,7 @@ export function MySkillsPage() {
setKeywordInput(event.target.value)}