From a211f60878ab7d419e08c4ffcbfdb0af62434dab Mon Sep 17 00:00:00 2001 From: Elio Hasrouni Date: Tue, 13 Oct 2020 16:36:28 -0400 Subject: [PATCH 1/8] Added new inputMode type that disables spinner --- src/components/TextField/TextField.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/TextField/TextField.tsx b/src/components/TextField/TextField.tsx index f69126d483d..10725cc98c1 100644 --- a/src/components/TextField/TextField.tsx +++ b/src/components/TextField/TextField.tsx @@ -43,6 +43,7 @@ type InputMode = | 'text' | 'decimal' | 'numeric' + | 'numeric-no-spinner' | 'tel' | 'search' | 'email' @@ -340,7 +341,10 @@ export function TextField({ ); const spinnerMarkup = - type === 'number' && !disabled && !readOnly ? ( + type === 'number' && + inputType !== 'numeric-no-spinner' && + !disabled && + !readOnly ? ( Date: Tue, 13 Oct 2020 16:57:31 -0400 Subject: [PATCH 2/8] Updated unreleased.md --- UNRELEASED.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UNRELEASED.md b/UNRELEASED.md index b95b08f0890..8ec62aa6d4b 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -8,6 +8,11 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f ### Enhancements +- Added `OutlineableAction` to the `ComplexAction` type ([#3405](https://github.com/Shopify/polaris-react/pull/3405)) +- Added `UnstyledButton` component and refactored `Banner` to use it ([#32326](https://github.com/Shopify/polaris-react/pull/32326)) +- Added `prefix` field to `options` prop on `Select` ([#3373](https://github.com/Shopify/polaris-react/pull/3373)) +- Added `numeric-no-spinner` type to `Textfield` to disable spinner ([#3477](https://github.com/Shopify/polaris-react/pull/3477)) + ### Bug fixes - Fixed alignment of badges in navigation items ([#3440](https://github.com/Shopify/polaris-react/pull/3440)) From d82a6c50daeffd997d37443f1f27ee4ba0090887 Mon Sep 17 00:00:00 2001 From: Elio Hasrouni Date: Wed, 14 Oct 2020 09:20:54 -0400 Subject: [PATCH 3/8] Fixed failing job run --- src/components/TextField/TextField.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TextField/TextField.tsx b/src/components/TextField/TextField.tsx index 10725cc98c1..3327047db48 100644 --- a/src/components/TextField/TextField.tsx +++ b/src/components/TextField/TextField.tsx @@ -342,7 +342,7 @@ export function TextField({ const spinnerMarkup = type === 'number' && - inputType !== 'numeric-no-spinner' && + inputMode !== 'numeric-no-spinner' && !disabled && !readOnly ? ( Date: Wed, 14 Oct 2020 14:41:05 -0400 Subject: [PATCH 4/8] Updated unreleased.md --- UNRELEASED.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/UNRELEASED.md b/UNRELEASED.md index 8ec62aa6d4b..4fb216c114e 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -8,19 +8,12 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f ### Enhancements -- Added `OutlineableAction` to the `ComplexAction` type ([#3405](https://github.com/Shopify/polaris-react/pull/3405)) -- Added `UnstyledButton` component and refactored `Banner` to use it ([#32326](https://github.com/Shopify/polaris-react/pull/32326)) -- Added `prefix` field to `options` prop on `Select` ([#3373](https://github.com/Shopify/polaris-react/pull/3373)) - Added `numeric-no-spinner` type to `Textfield` to disable spinner ([#3477](https://github.com/Shopify/polaris-react/pull/3477)) ### Bug fixes -- Fixed alignment of badges in navigation items ([#3440](https://github.com/Shopify/polaris-react/pull/3440)) - ### Documentation -- The Details Page in Storybook now renders the `SearchDismissOverlay` when typing in the search field. ([#3471](https://github.com/Shopify/polaris-react/pull/3471)) - ### Development workflow ### Dependency upgrades From 2b033c23824efaec671b7918cee8d8ab67b6d742 Mon Sep 17 00:00:00 2001 From: Elio Hasrouni Date: Thu, 15 Oct 2020 11:11:19 -0400 Subject: [PATCH 5/8] Added "step=0" to disable spinner, reverted old changes --- UNRELEASED.md | 2 +- src/components/TextField/TextField.tsx | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/UNRELEASED.md b/UNRELEASED.md index 4fb216c114e..fc3f5161461 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -8,7 +8,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f ### Enhancements -- Added `numeric-no-spinner` type to `Textfield` to disable spinner ([#3477](https://github.com/Shopify/polaris-react/pull/3477)) +- Added `step='0'` check to `Textfield` to disable spinner with input type 'number' ([#3477](https://github.com/Shopify/polaris-react/pull/3477)) ### Bug fixes diff --git a/src/components/TextField/TextField.tsx b/src/components/TextField/TextField.tsx index 3327047db48..b2763f44cf5 100644 --- a/src/components/TextField/TextField.tsx +++ b/src/components/TextField/TextField.tsx @@ -43,7 +43,6 @@ type InputMode = | 'text' | 'decimal' | 'numeric' - | 'numeric-no-spinner' | 'tel' | 'search' | 'email' @@ -341,10 +340,7 @@ export function TextField({ ); const spinnerMarkup = - type === 'number' && - inputMode !== 'numeric-no-spinner' && - !disabled && - !readOnly ? ( + type === 'number' && step !== '0' && !disabled && !readOnly ? ( Date: Thu, 15 Oct 2020 12:00:16 -0400 Subject: [PATCH 6/8] Changed type from string to int --- src/components/TextField/TextField.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TextField/TextField.tsx b/src/components/TextField/TextField.tsx index b2763f44cf5..97a0685c681 100644 --- a/src/components/TextField/TextField.tsx +++ b/src/components/TextField/TextField.tsx @@ -340,7 +340,7 @@ export function TextField({ ); const spinnerMarkup = - type === 'number' && step !== '0' && !disabled && !readOnly ? ( + type === 'number' && step !== 0 && !disabled && !readOnly ? ( Date: Mon, 19 Oct 2020 16:51:43 -0400 Subject: [PATCH 7/8] Added a test following PR comment --- UNRELEASED.md | 4 ++-- src/components/TextField/tests/TextField.test.tsx | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/UNRELEASED.md b/UNRELEASED.md index fc3f5161461..fef99d62aa1 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -8,8 +8,8 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f ### Enhancements -- Added `step='0'` check to `Textfield` to disable spinner with input type 'number' ([#3477](https://github.com/Shopify/polaris-react/pull/3477)) - + Updated `Textfield` with a `type` of `number` to not render a spinner if step is set to `0` ([#3477](https://github.com/Shopify/polaris-react/pull/3477)) + ### Bug fixes ### Documentation diff --git a/src/components/TextField/tests/TextField.test.tsx b/src/components/TextField/tests/TextField.test.tsx index 97dc8859071..96f5ee7f891 100644 --- a/src/components/TextField/tests/TextField.test.tsx +++ b/src/components/TextField/tests/TextField.test.tsx @@ -704,6 +704,18 @@ describe('', () => { expect(element.find(Spinner)).toHaveLength(0); }); + it('removes spinner buttons when type is number and step is 0', () => { + const element = mountWithAppProvider( + , + ); + expect(element.find(Spinner)).toHaveLength(0); + }); + it('increments by step when value, step, or both are float numbers', () => { const spy = jest.fn(); const element = mountWithAppProvider( From b4adaec510341fc84d67f17300cb536384efec1f Mon Sep 17 00:00:00 2001 From: Elio Hasrouni Date: Tue, 20 Oct 2020 08:34:53 -0400 Subject: [PATCH 8/8] Fixed a linting issue, added onChange to test --- UNRELEASED.md | 4 ++-- src/components/TextField/tests/TextField.test.tsx | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/UNRELEASED.md b/UNRELEASED.md index fef99d62aa1..0b000825b22 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -8,8 +8,8 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f ### Enhancements - Updated `Textfield` with a `type` of `number` to not render a spinner if step is set to `0` ([#3477](https://github.com/Shopify/polaris-react/pull/3477)) - +Updated `Textfield` with a `type` of `number` to not render a spinner if step is set to `0` ([#3477](https://github.com/Shopify/polaris-react/pull/3477)) + ### Bug fixes ### Documentation diff --git a/src/components/TextField/tests/TextField.test.tsx b/src/components/TextField/tests/TextField.test.tsx index 96f5ee7f891..b45eb4fe9d8 100644 --- a/src/components/TextField/tests/TextField.test.tsx +++ b/src/components/TextField/tests/TextField.test.tsx @@ -705,12 +705,14 @@ describe('', () => { }); it('removes spinner buttons when type is number and step is 0', () => { + const spy = jest.fn(); const element = mountWithAppProvider( , ); expect(element.find(Spinner)).toHaveLength(0);