-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Backdrop] Call onClick
regardless of setClosing
prop presence
#8237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/snapit |
🫰✨ Thanks @loic-d! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-cli@0.0.0-snapshot-release-20230201184728 yarn add @shopify/polaris@0.0.0-snapshot-release-20230201184728 |
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @loic-d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch and fix!
Removes null check Linting
7cfbfdb
to
4d84b1b
Compare
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @shopify/polaris@10.25.0 ### Minor Changes - [#7950](#7950) [`286c63a84`](286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Updated `Tabs` component to use layout primitives - [#7950](#7950) [`286c63a84`](286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Updated `OptionList` to use new layout primitives - [#7950](#7950) [`286c63a84`](286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Updated `Popover` to use new layout primitives ### Patch Changes - [#7950](#7950) [`286c63a84`](286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Remove unused class in Page Header - [#7950](#7950) [`286c63a84`](286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Rebuilt Page Header with layout components - [#8237](#8237) [`17fa970db`](17fa970) Thanks [@loic-d](https://github.com/loic-d)! - Fixed Backdrop onClick callback when setClosing is missing ## @shopify/polaris-cli@0.1.1 ## polaris.shopify.com@0.31.1 ### Patch Changes - [#8235](#8235) [`5fbe75461`](5fbe754) Thanks [@laurkim](https://github.com/laurkim)! - Updated Patterns/Typography copy to include suggestions for uppercase typography styles - Updated dependencies \[[`286c63a84`](286c63a), [`286c63a84`](286c63a), [`286c63a84`](286c63a), [`286c63a84`](286c63a), [`286c63a84`](286c63a), [`17fa970db`](17fa970)]: - @shopify/polaris@10.25.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…hopify#8237) <!-- ☝️How to write a good PR title: - Prefix it with [ComponentName] (if applicable), for example: [Button] - Start with a verb, for example: Add, Delete, Improve, Fix… - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ### WHY are these changes introduced? I believe Shopify#8090 introduced a regression where the `onClick` prop of the `Backdrop` component is not called when the consumer of the component also doesn't provide `setClosing` as a prop (released in Polaris `10.23.0`). There are various occurrences of Web Admin using `Backdrop` without providing `setClosing` as a prop, so some sheets are not properly closing when clicking outside. For example in Customer Segmentation: <img width="1428" alt="Screenshot 2023-02-01 at 1 40 45 PM" src="https://user-images.githubusercontent.com/3925905/216133586-92b760bf-57c2-4bfd-9f46-3382d8f935c2.png"> You can reproduce the issue in this [CodeSandbox](https://codesandbox.io/s/condescending-cannon-7om9z7?file=/App.js:115-155). Switching to a version of Polaris < `10.23.0` fixes the issue. ### WHAT is this pull request doing? This PR ensures `onClick` is always called, regardless of `setClosing` being provided. ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) <!-- Give as much information as needed to experiment with the component in the playground. --> See Playground code. After opening the backdrop, clicking on it again should properly close it. <details> <summary>Copy-paste this code in <code>playground/Playground.tsx</code>:</summary> ```jsx import React, {useState} from 'react'; import {Backdrop, Button, Page} from '../src'; export function Playground() { const [open, setOpen] = useState(false); return ( <Page title="Playground"> <div style={{ position: "absolute", zIndex: 999999 }}> <Button onClick={() => setOpen(!open)}>Toggle backdrop</Button> </div> {open && ( <Backdrop setClosing={() => {}} onClick={() => { console.log("onClick from Backdrop"); setOpen(false); }} /> )} </Page> ); } ``` </details> You can also 🎩 directly in Admin using this [Spin instance](https://admin.web.customer-data-platform-ujet.loic-delaubier.us.spin.dev/store/shop1/customers): - Go to the Customers section - Open Segmentation templates <img width="1189" alt="Screenshot 2023-02-01 at 2 18 18 PM" src="https://user-images.githubusercontent.com/3925905/216141402-c395b9df-8990-4315-84ca-c88607b759fd.png"> - Click outside of the sheet. The sheet should properly close. ### 🎩 checklist - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @shopify/polaris@10.25.0 ### Minor Changes - [Shopify#7950](Shopify#7950) [`286c63a84`](Shopify@286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Updated `Tabs` component to use layout primitives - [Shopify#7950](Shopify#7950) [`286c63a84`](Shopify@286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Updated `OptionList` to use new layout primitives - [Shopify#7950](Shopify#7950) [`286c63a84`](Shopify@286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Updated `Popover` to use new layout primitives ### Patch Changes - [Shopify#7950](Shopify#7950) [`286c63a84`](Shopify@286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Remove unused class in Page Header - [Shopify#7950](Shopify#7950) [`286c63a84`](Shopify@286c63a) Thanks [@laurkim](https://github.com/laurkim)! - Rebuilt Page Header with layout components - [Shopify#8237](Shopify#8237) [`17fa970db`](Shopify@17fa970) Thanks [@loic-d](https://github.com/loic-d)! - Fixed Backdrop onClick callback when setClosing is missing ## @shopify/polaris-cli@0.1.1 ## polaris.shopify.com@0.31.1 ### Patch Changes - [Shopify#8235](Shopify#8235) [`5fbe75461`](Shopify@5fbe754) Thanks [@laurkim](https://github.com/laurkim)! - Updated Patterns/Typography copy to include suggestions for uppercase typography styles - Updated dependencies \[[`286c63a84`](Shopify@286c63a), [`286c63a84`](Shopify@286c63a), [`286c63a84`](Shopify@286c63a), [`286c63a84`](Shopify@286c63a), [`286c63a84`](Shopify@286c63a), [`17fa970db`](Shopify@17fa970)]: - @shopify/polaris@10.25.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
WHY are these changes introduced?
I believe #8090 introduced a regression where the
onClick
prop of theBackdrop
component is not called when the consumer of the component also doesn't providesetClosing
as a prop (released in Polaris10.23.0
). There are various occurrences of Web Admin usingBackdrop
without providingsetClosing
as a prop, so some sheets are not properly closing when clicking outside. For example in Customer Segmentation:You can reproduce the issue in this CodeSandbox. Switching to a version of Polaris <
10.23.0
fixes the issue.WHAT is this pull request doing?
This PR ensures
onClick
is always called, regardless ofsetClosing
being provided.How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
See Playground code. After opening the backdrop, clicking on it again should properly close it.
Copy-paste this code in
playground/Playground.tsx
:You can also 🎩 directly in Admin using this Spin instance:
🎩 checklist
README.md
with documentation changes