Skip to content

Commit

Permalink
Feedback | Concept split view to close on url change
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Oct 16, 2024
1 parent f251fac commit b2f6f81
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/concepts/ConceptHome.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { useLocation } from 'react-router-dom'
import { useTranslation } from 'react-i18next';
import APIService from '../../services/APIService';
import ConceptHeader from './ConceptHeader';
Expand All @@ -10,6 +11,9 @@ import Associations from './Associations'

const ConceptHome = props => {
const { t } = useTranslation()
const location = useLocation()
const isInitialMount = React.useRef(true);

const [concept, setConcept] = React.useState(props.concept || {})
const [mappings, setMappings] = React.useState([])
const [reverseMappings, setReverseMappings] = React.useState([])
Expand All @@ -26,6 +30,14 @@ const ConceptHome = props => {
})
}, [props.url])

React.useEffect(() => {
if (isInitialMount.current) {
isInitialMount.current = false;
} else {
props?.onClose()
}
}, [location])

const fetchRepo = _concept => APIService.new().overrideURL(getRepoURL(_concept)).get().then(response => setRepo(response.data))

const getRepoURL = _concept => {
Expand Down Expand Up @@ -83,8 +95,6 @@ const ConceptHome = props => {
})
}



return (concept?.id && repo?.id) ? (
<>
<Fade in={edit}>
Expand Down

0 comments on commit b2f6f81

Please sign in to comment.