Skip to content

Commit 730349b

Browse files
authored
Fixing TextField clear button in Safari (#13413)
### WHY are these changes introduced? The clear button in TextField components were not working in Safari. This bug was raised previously (issue linked below) and a fix was merged in _polaris-internal_. The fix merged in _polaris-internal_ can be seen here Shopify/polaris-internal#895 This PR adds the same fix into the external Polaris version. Fixes Shopify/merchant-to-merchant#20327 ### How to 🎩 1. Checkout this branch on local dev 2. Open Storybook in Safari and navigate to the _TextField > With Clear Button_ story 3. Click on the clear button and the text should clear and the textfield should still remain focused. 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#install-dependencies-and-build-workspaces) 🗒 [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) ### 🎩 checklist - [x] Tested a [snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases) - [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
1 parent adbab05 commit 730349b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.changeset/chatty-glasses-deny.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Fixed TextField clear bug in Safari

polaris-react/src/components/TextField/TextField.module.css

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
/* only show the clear button when focused within the textfield */
1919
&:focus-within {
2020
.ClearButton {
21-
display: block;
2221
visibility: visible;
2322
opacity: 1;
2423
}
@@ -31,9 +30,10 @@
3130

3231
&:not(:focus-within) {
3332
.ClearButton {
34-
display: none;
3533
visibility: hidden;
3634
opacity: 0;
35+
position: absolute;
36+
right: 0;
3737
}
3838
}
3939

@@ -474,9 +474,8 @@
474474
/* stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY */
475475
z-index: var(--pc-text-field-contents);
476476
margin: 0 var(--p-space-300) 0 var(--p-space-100);
477-
transition: visibility var(--p-motion-duration-200)
478-
var(--p-motion-ease-in-out),
479-
opacity var(--p-motion-duration-200) var(--p-motion-ease-in-out);
477+
transition: visibility var(--p-motion-duration-100) var(--p-motion-ease-out),
478+
opacity var(--p-motion-duration-100) var(--p-motion-ease-out);
480479

481480
&:focus-visible:enabled {
482481
/* stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY */

0 commit comments

Comments
 (0)