1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-25 22:46:31 -04:00

Fix issues with Floating UI

This commit is contained in:
Mark McDowall
2025-04-07 16:09:25 -07:00
parent f7eece32e7
commit e52b68ee7d
5 changed files with 74 additions and 60 deletions
+23 -10
View File
@@ -58,16 +58,6 @@ function Menu({
onPress: handleMenuButtonPress,
});
const handleFloaterPress = useCallback((_event: MouseEvent) => {
// TODO: Menu items should handle closing when they are clicked.
// This is handled before the menu item click event is handled, so wait 100ms before closing.
setTimeout(() => {
setIsMenuOpen(false);
}, 100);
return true;
}, []);
const handleWindowResize = useCallback(() => {
updateMaxHeight();
}, [updateMaxHeight]);
@@ -118,8 +108,31 @@ function Menu({
onOpenChange: setIsMenuOpen,
});
const handleFloaterPress = useCallback(
(event: MouseEvent) => {
if (
refs.reference &&
(refs.reference.current as HTMLElement).contains(
event.target as HTMLElement
)
) {
return false;
}
// TODO: Menu items should handle closing when they are clicked.
// This is handled before the menu item click event is handled, so wait 100ms before closing.
setTimeout(() => {
setIsMenuOpen(false);
}, 100);
return true;
},
[refs.reference]
);
const click = useClick(context);
const dismiss = useDismiss(context, {
outsidePressEvent: 'click',
outsidePress: handleFloaterPress,
});