Skip to content

Commit

Permalink
EditDialog: fix ParentsEditor for new node (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz authored Dec 27, 2024
1 parent c390fd0 commit fa75033
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { getApiId, getShortId } from '../../../../services/helpers';
import { fetchSchemaTranslations } from '../../../../services/tagging/translations';
import { useEditContext } from '../EditContext';
import { FeatureRow } from './FeatureRow';
import { items } from '../../QuickActions/ShareDialog/items';
import { t } from '../../../../services/intl';

export const ParentsEditor = () => {
Expand All @@ -25,13 +24,14 @@ export const ParentsEditor = () => {
const { addFeature, setCurrent, items } = useEditContext();

useEffect(() => {
const fetchParents = async () => {
const data = await fetchParentFeatures(getApiId(shortId));
(async () => {
setParents([]);
if (getApiId(shortId).id < 0) {
return;
}

setParents(data);
};

fetchParents();
setParents(await fetchParentFeatures(getApiId(shortId)));
})();
}, [shortId]);

if (!parents || parents.length === 0) return null;
Expand Down

0 comments on commit fa75033

Please sign in to comment.