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
5 changes: 5 additions & 0 deletions .changeset/gentle-chefs-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

Replaced mouse up and down events on Backdrop with onClick to close Modal
5 changes: 2 additions & 3 deletions polaris-react/src/components/Backdrop/Backdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function Backdrop(props: BackdropProps) {
}
};

const handleMouseUp = () => {
const handleClick = () => {
if (setClosing && onClick) {
setClosing(false);
onClick();
Expand All @@ -41,10 +41,9 @@ export function Backdrop(props: BackdropProps) {
<ScrollLock />
<div
className={className}
onClick={onClick}
onClick={handleClick}
onTouchStart={onTouchStart}
onMouseDown={handleMouseDown}
onMouseUp={handleMouseUp}
/>
</>
);
Expand Down
8 changes: 5 additions & 3 deletions polaris-react/src/components/Backdrop/tests/Backdrop.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import {mountWithApp} from 'tests/utilities';
import {Backdrop} from '..';

describe('<Backdrop />', () => {
describe('onDismiss()', () => {
describe('onClick()', () => {
it('is called when the backdrop is clicked', () => {
const spy = jest.fn();
const backdrop = mountWithApp(<Backdrop onClick={spy} />);
backdrop.find('div', {onClick: spy})!.trigger('onClick');
const backdrop = mountWithApp(
<Backdrop onClick={spy} setClosing={() => {}} />,
);
backdrop.find('div')!.trigger('onClick');
expect(spy).toHaveBeenCalled();
});
});
Expand Down