[#277] fixed conditions to prevent blink in compact event chips (#280)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2025-11-04 14:18:55 +01:00
committed by GitHub
parent 2d0803090a
commit 838262fde3
2 changed files with 33 additions and 30 deletions
+1 -29
View File
@@ -19,10 +19,10 @@ import {
getOwnerAttendee,
getTitleStyle,
IconDisplayConfig,
useCompactMode,
} from "./EventChipUtils";
import { SimpleEventChip } from "./SimpleEventChip";
const COMPACT_WIDTH_THRESHOLD = 100;
const PRIVATE_CLASSIFICATIONS = ["PRIVATE", "CONFIDENTIAL"];
export const EVENT_DURATION = {
@@ -31,34 +31,6 @@ export const EVENT_DURATION = {
LONG: 60,
} as const;
function useCompactMode(
cardRef: React.RefObject<HTMLDivElement | null>
): boolean {
const [showCompact, setShowCompact] = useState(false);
useEffect(() => {
const checkWidth = () => {
if (cardRef.current) {
const width = cardRef.current.offsetWidth;
setShowCompact(width < COMPACT_WIDTH_THRESHOLD);
}
};
checkWidth();
const resizeObserver = new ResizeObserver(checkWidth);
if (cardRef.current) {
resizeObserver.observe(cardRef.current);
}
return () => {
resizeObserver.disconnect();
};
}, []);
return showCompact;
}
export function EventChip({
arg,
calendars,