feat(assignee-selector, labels-selector): improve dropdown visibility handling
- Enhanced dropdown behavior by checking button visibility in the viewport before updating position. - Added logic to hide the dropdown if the button is not visible, improving user experience during scrolling.
This commit is contained in:
@@ -63,7 +63,20 @@ const AssigneeSelector: React.FC<AssigneeSelectorProps> = ({
|
|||||||
|
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
updateDropdownPosition();
|
// Check if the button is still visible in the viewport
|
||||||
|
if (buttonRef.current) {
|
||||||
|
const rect = buttonRef.current.getBoundingClientRect();
|
||||||
|
const isVisible = rect.top >= 0 && rect.left >= 0 &&
|
||||||
|
rect.bottom <= window.innerHeight &&
|
||||||
|
rect.right <= window.innerWidth;
|
||||||
|
|
||||||
|
if (isVisible) {
|
||||||
|
updateDropdownPosition();
|
||||||
|
} else {
|
||||||
|
// Hide dropdown if button is not visible
|
||||||
|
setIsOpen(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,20 @@ const LabelsSelector: React.FC<LabelsSelectorProps> = ({
|
|||||||
|
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
updateDropdownPosition();
|
// Check if the button is still visible in the viewport
|
||||||
|
if (buttonRef.current) {
|
||||||
|
const rect = buttonRef.current.getBoundingClientRect();
|
||||||
|
const isVisible = rect.top >= 0 && rect.left >= 0 &&
|
||||||
|
rect.bottom <= window.innerHeight &&
|
||||||
|
rect.right <= window.innerWidth;
|
||||||
|
|
||||||
|
if (isVisible) {
|
||||||
|
updateDropdownPosition();
|
||||||
|
} else {
|
||||||
|
// Hide dropdown if button is not visible
|
||||||
|
setIsOpen(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user