Skip to content
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

Input: Clear icon doesn't disappear if value is null (vs undefined or empy string) #14733

Merged
merged 2 commits into from
Feb 7, 2019
Merged

Conversation

thilo-behnke
Copy link
Contributor

This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Branch merge
  • Other (about what?)

What's the background?

If the value becomes null in the Input component, the clear icon is still shown if activated (setting allowClear).
See example: https://codesandbox.io/s/7jp07nyp9x

A check for null needed to be introduced in Input.tsx.

Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@codecov
Copy link

codecov bot commented Feb 5, 2019

Codecov Report

Merging #14733 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #14733   +/-   ##
=======================================
  Coverage   82.35%   82.35%           
=======================================
  Files          13       13           
  Lines          17       17           
  Branches        3        3           
=======================================
  Hits           14       14           
  Misses          3        3

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b558af...b15a38a. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 5, 2019

Codecov Report

Merging #14733 into master will increase coverage by 10.38%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #14733       +/-   ##
===========================================
+ Coverage   82.35%   92.73%   +10.38%     
===========================================
  Files          13      236      +223     
  Lines          17     6222     +6205     
  Branches        3     1854     +1851     
===========================================
+ Hits           14     5770     +5756     
- Misses          3      449      +446     
- Partials        0        3        +3
Impacted Files Coverage Δ
components/input/Input.tsx 100% <100%> (ø)
components/affix/index.tsx 86.06% <0%> (-13.94%) ⬇️
components/back-top/index.tsx 91.93% <0%> (-8.07%) ⬇️
components/config-provider/index.tsx 93.1% <0%> (-6.9%) ⬇️
components/tree-select/index.tsx 94.44% <0%> (-5.56%) ⬇️
components/notification/index.tsx 95.94% <0%> (-4.06%) ⬇️
components/badge/index.tsx 100% <0%> (ø) ⬆️
components/popover/index.tsx 100% <0%> (ø) ⬆️
components/switch/index.tsx 100% <0%> (ø) ⬆️
components/steps/index.tsx 100% <0%> (ø) ⬆️
... and 227 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b558af...90b0ad0. Read the comment docs.

@netlify
Copy link

netlify bot commented Feb 5, 2019

Deploy preview for ant-design ready!

Built with commit 90b0ad0

https://deploy-preview-14733--ant-design.netlify.com

@afc163
Copy link
Member

afc163 commented Feb 6, 2019

Cloud you add a test case?

Copy link

@accesslint accesslint bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are accessibility issues in these changes.

defaultValue={null}
disabled={false}
type="text"
>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.

@@ -134,6 +136,26 @@ describe('Input allowClear', () => {
expect(wrapper.find('input').getDOMNode().value).toEqual('');
});

it('should not show icon if value is undefined, null or empty string', () => {
const wrappers = [null, undefined, ''].map(val => mount(<Input allowClear value={val} />));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.

style={null}
type="text"
value=""
/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.


it('should not show icon if defaultValue is undefined, null or empty string', () => {
const wrappers = [null, undefined, ''].map(val =>
mount(<Input allowClear defaultValue={val} />),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.

allowClear={true}
disabled={false}
type="text"
>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.

style={null}
type="text"
value=""
/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.

allowClear={true}
disabled={false}
type="text"
>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.

style={null}
type="text"
value=""
/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.

disabled={false}
type="text"
value=""
>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.

style={null}
type="text"
value=""
/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. If you don't want a visual label, try an aria-label attribute.

@thilo-behnke
Copy link
Contributor Author

Thanks for your review. As requested by @afc163 I added a test each for value and defaultValue.
I see that there are some linting warnings in the snapshot file, but they seem irrelevant to me.

Can this be merged?

@afc163
Copy link
Member

afc163 commented Feb 6, 2019

@zombieJ Something wrong of ci in master.

@zombieJ
Copy link
Member

zombieJ commented Feb 6, 2019

@zombieJ Something wrong of ci in master.

Seems react@16.8.0 released: facebook/react#14764

@zombieJ zombieJ merged commit a9a6da4 into ant-design:master Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants