Skip to content

Commit

Permalink
fix: handle router state edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
annavik committed Jan 8, 2025
1 parent c9e1d28 commit e5d82e1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ui/src/pages/occurrences/occurrences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,18 @@ const OccurrenceDetailsDialog = ({
}) => {
const navigate = useNavigate()
const { state } = useLocation()
const { selectedView, setSelectedView } = useSelectedView(
state?.defaultTab ?? TABS.FIELDS,
'tab'
)
const { selectedView, setSelectedView } = useSelectedView(TABS.FIELDS, 'tab')
const { projectId } = useParams()
const { setDetailBreadcrumb } = useContext(BreadcrumbContext)
const { occurrence, isLoading, error } = useOccurrenceDetails(id)

useEffect(() => {
// If a default tab is set from router state, set this as active
if (state?.defaultTab) {
setSelectedView(state.defaultTab)
}
}, [state?.defaultTab])

useEffect(() => {
setDetailBreadcrumb(
occurrence ? { title: occurrence.displayName } : undefined
Expand Down

0 comments on commit e5d82e1

Please sign in to comment.