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/unlucky-bags-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

Fixed Backdrop onClick callback when setClosing is missing
5 changes: 4 additions & 1 deletion polaris-react/src/components/Backdrop/Backdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ export function Backdrop(props: BackdropProps) {
};

const handleClick = () => {
if (setClosing && onClick) {
if (setClosing) {
setClosing(false);
}

if (onClick) {
onClick();
}
};
Expand Down
13 changes: 10 additions & 3 deletions polaris-react/src/components/Backdrop/tests/Backdrop.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ describe('<Backdrop />', () => {
describe('onClick()', () => {
it('is called when the backdrop is clicked', () => {
const spy = jest.fn();
const backdrop = mountWithApp(
<Backdrop onClick={spy} setClosing={() => {}} />,
);
const backdrop = mountWithApp(<Backdrop onClick={spy} />);
backdrop.find('div')!.trigger('onClick');
expect(spy).toHaveBeenCalled();
});
});

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