-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TextField] Fix position of loading spinner when there is no clear bu…
…tton visible (#11466) ### WHY are these changes introduced? The loading spinner currently sits flat against the right-hand edge of the TextField when there is no clear button visible on screen, which we do not want. This PR adds some margin between the loading spinner and the edge of the TextField in this case, and makes sure to remove the margin when there is both the loading spinner and clear button present. Before: <img width="1624" alt="Screenshot 2024-01-18 at 12 06 40" src="https://github.com/Shopify/polaris/assets/2562596/bff82a29-8cc2-4491-a394-ba5eeae946f4"> After: <img width="1624" alt="Screenshot 2024-01-18 at 12 16 44" src="https://github.com/Shopify/polaris/assets/2562596/5438b423-2a2a-4307-9e6a-41d5d90006b2"> ### How to 🎩 🖥 [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) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
- Loading branch information
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@shopify/polaris': patch | ||
'polaris.shopify.com': patch | ||
--- | ||
|
||
[TextField] Fixed positional issue of loading indicator when no clear button is present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
polaris.shopify.com/pages/examples/text-field-with-loading.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {TextField} from '@shopify/polaris'; | ||
import {useState, useCallback} from 'react'; | ||
import {withPolarisExample} from '../../src/components/PolarisExampleWrapper'; | ||
|
||
function LoadingExample() { | ||
const [value, setValue] = useState(''); | ||
|
||
const handleChange = useCallback( | ||
(newValue: string) => setValue(newValue), | ||
[], | ||
); | ||
|
||
const handleClearButtonClick = useCallback(() => setValue(''), []); | ||
|
||
return ( | ||
<TextField | ||
label="Store name" | ||
value={value} | ||
onChange={handleChange} | ||
autoComplete="off" | ||
clearButton | ||
onClearButtonClick={handleClearButtonClick} | ||
loading | ||
/> | ||
); | ||
} | ||
|
||
export default withPolarisExample(LoadingExample); |