|
|
@@ -1,4 +1,4 @@
|
|
|
-import { useEffect, useMemo, useState } from 'react'
|
|
|
+import { useEffect, useMemo, useRef, useState } from 'react'
|
|
|
import ErrorState from '../../components/ErrorState.jsx'
|
|
|
import LoadingState from '../../components/LoadingState.jsx'
|
|
|
import DecodeKnowledgeModal from '../decode/DecodeKnowledgeModal.jsx'
|
|
|
@@ -53,6 +53,7 @@ export default function QueryBoardPage() {
|
|
|
const [selectedQuery, setSelectedQuery] = useState(null)
|
|
|
const [decodeItemId, setDecodeItemId] = useState('')
|
|
|
const [manualMode, setManualMode] = useState('')
|
|
|
+ const didSetDefaultTab = useRef(false)
|
|
|
|
|
|
const families = useMemo(() => {
|
|
|
const base = preview?.families || []
|
|
|
@@ -72,22 +73,18 @@ export default function QueryBoardPage() {
|
|
|
}, [lastUpdatedAt])
|
|
|
|
|
|
useEffect(() => {
|
|
|
- const resetDefaultTab = () => {
|
|
|
- if ((window.location.hash || '#/') === '#/') {
|
|
|
- setActiveKey('f1')
|
|
|
- }
|
|
|
+ if (!didSetDefaultTab.current && (window.location.hash || '#/') === '#/' && families.some((row) => row.key === 'f1')) {
|
|
|
+ didSetDefaultTab.current = true
|
|
|
+ setActiveKey('f1')
|
|
|
}
|
|
|
- resetDefaultTab()
|
|
|
- window.addEventListener('pageshow', resetDefaultTab)
|
|
|
- return () => window.removeEventListener('pageshow', resetDefaultTab)
|
|
|
- }, [])
|
|
|
+ }, [families])
|
|
|
|
|
|
useEffect(() => {
|
|
|
const firstKey = families[0]?.key
|
|
|
- if (firstKey && !families.some((row) => row.key === activeKey)) {
|
|
|
+ if (firstKey && !families.some((row) => row.key === activeKey) && preview) {
|
|
|
setActiveKey(firstKey)
|
|
|
}
|
|
|
- }, [families, activeKey])
|
|
|
+ }, [families, activeKey, preview])
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (!familyItems.length) {
|