Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: `useOnClickOutside` should invoke callback on clicking scrollbar",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('useOnClickOutside', () => {
jest.useRealTimers();
});

const supportedEvents = ['click', 'touchstart', 'contextmenu', 'fuiframefocus', 'mousedown'];
const supportedEvents = ['mouseup', 'touchstart', 'fuiframefocus', 'mousedown'];

it.each(supportedEvents)('should add %s listener', event => {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ export const useOnClickOutside = (options: UseOnClickOrScrollOutsideOptions) =>
};

// use capture phase because React can update DOM before the event bubbles to the document
element?.addEventListener('click', conditionalHandler, true);
element?.addEventListener('touchstart', conditionalHandler, true);
element?.addEventListener('contextmenu', conditionalHandler, true);
element?.addEventListener('mouseup', conditionalHandler, true);
element?.addEventListener('mousedown', handleMouseDown, true);

// Garbage collect this event after it's no longer useful to avoid memory leaks
Expand All @@ -104,9 +103,8 @@ export const useOnClickOutside = (options: UseOnClickOrScrollOutsideOptions) =>
}, 1);

return () => {
element?.removeEventListener('click', conditionalHandler, true);
element?.removeEventListener('touchstart', conditionalHandler, true);
element?.removeEventListener('contextmenu', conditionalHandler, true);
element?.removeEventListener('mouseup', conditionalHandler, true);
element?.removeEventListener('mousedown', handleMouseDown, true);

clearTimeout(timeoutId.current);
Expand Down