Fix From Many relation for deleted notes crashing (#11117)

In this PR, I'm: 
- fixing the root cause (we should not try to render a RecordChip if the
record is not defined in RelationFromMany Display)
- fixing related typing issues
- we won't be able to catch the issue from TS perspective as
ObjectRecord is a Record of string, any
This commit is contained in:
Charles Bochet
2025-03-24 13:29:44 +01:00
committed by GitHub
parent 3ec72a2bca
commit 6e7d2db58f
5 changed files with 30 additions and 18 deletions

View File

@ -1,4 +1,4 @@
import { useEffect } from 'react';
import { useEffect, useState } from 'react';
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
@ -10,14 +10,20 @@ export const DropdownOnToggleEffect = ({
onDropdownOpen?: () => void;
}) => {
const { isDropdownOpen } = useDropdown();
const [currentIsDropdownOpen, setCurrentIsDropdownOpen] =
useState(isDropdownOpen);
useEffect(() => {
if (isDropdownOpen) {
if (isDropdownOpen && !currentIsDropdownOpen) {
setCurrentIsDropdownOpen(isDropdownOpen);
onDropdownOpen?.();
} else {
}
if (!isDropdownOpen && currentIsDropdownOpen) {
setCurrentIsDropdownOpen(isDropdownOpen);
onDropdownClose?.();
}
}, [isDropdownOpen, onDropdownClose, onDropdownOpen]);
}, [currentIsDropdownOpen, isDropdownOpen, onDropdownClose, onDropdownOpen]);
return null;
};