Skip to content

Commit c370521

Browse files
committed
📚 Update docs (#1907)
1 parent 902304b commit c370521

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lib/actions/handle_dropdown.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ let resizeTimeout: ReturnType<typeof setTimeout>;
1414
* - Closing when clicking outside the dropdown
1515
* - Closing on page scroll
1616
* - Coordinating with other dropdowns to ensure only one is open at a time
17+
* - Recalculating the dropdown position on window resize
1718
*
1819
* @param node - The HTML element that contains the dropdown
1920
* @param options - Configuration options for the dropdown behavior
@@ -76,7 +77,7 @@ export function handleDropdownBehavior(
7677
};
7778

7879
// Recalculate the dropdown position on resize.
79-
const handleResize = () => {
80+
const handleWindowResize = () => {
8081
if (options.isOpen) {
8182
options.closeDropdown();
8283
}
@@ -101,7 +102,7 @@ export function handleDropdownBehavior(
101102
// Add event listeners.
102103
window.addEventListener('click', handleWindowClick);
103104
window.addEventListener('scroll', handleScroll, { passive: true });
104-
window.addEventListener('resize', handleResize, { passive: true });
105+
window.addEventListener('resize', handleWindowResize, { passive: true });
105106

106107
return {
107108
update(newOptions: {
@@ -119,7 +120,7 @@ export function handleDropdownBehavior(
119120
// Remove event listeners to prevent memory leaks.
120121
window.removeEventListener('scroll', handleScroll);
121122
window.removeEventListener('click', handleWindowClick);
122-
window.removeEventListener('resize', handleResize);
123+
window.removeEventListener('resize', handleWindowResize);
123124

124125
clearTimeout(resizeTimeout);
125126
unsubscribe();

0 commit comments

Comments
 (0)