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

fix(checkbox): pass disabled prop to input #2800

Merged
merged 3 commits into from
May 18, 2018

Conversation

ofir-shapira-como
Copy link
Contributor

There is an issue with the input element that is created by <Checkbox>.

When the <Checkbox> is disabled, the input is not disabled and it allows to focus on the element.
See an example in: https://codesandbox.io/s/3x9rn7lo5

The proposed solution is to add disabled attribute to the input in case the user asks the <Checkbox> to be disabled.

@welcome
Copy link

welcome bot commented May 15, 2018

💖 Thanks for opening this pull request! 💖

Here is a list of things that will help get it across the finish line:

  • Run yarn lint locally to catch formatting errors. This will fix some errors automatically, commit and push any changes.
  • Run yarn test locally to catch errors. This ensures all components still behave as they should.
  • Run yarn start to run the doc site locally and try a few pages, ensuring everything is in good working order.
  • Include tests when adding/changing behavior.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@@ -250,6 +237,7 @@ export default class Checkbox extends Component {
{...htmlInputProps}
checked={checked}
className='hidden'
disabled={disabled}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the actual change, passing disabled attribute to the input if set as a prop to Checkbox

@codecov-io
Copy link

codecov-io commented May 15, 2018

Codecov Report

Merging #2800 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2800   +/-   ##
=======================================
  Coverage   99.74%   99.74%           
=======================================
  Files         160      160           
  Lines        2762     2762           
=======================================
  Hits         2755     2755           
  Misses          7        7
Impacted Files Coverage Δ
src/modules/Checkbox/Checkbox.js 100% <100%> (ø) ⬆️

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 447f96b...9488713. Read the comment docs.

@levithomason
Copy link
Member

Thanks much! Let's add a test for this. The <Input /> has an identical test for asserting disabled is properly passed. You can see it here:

describe('disabled', () => {

wrapper.find('input').should.be.checked()
})

it('is applied to the underlying html input element', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are the tests, better to review in Split mode as GitHub did a diff mess because of the Lint

@ofir-shapira-como
Copy link
Contributor Author

@levithomason - done, added two tests, one check for when disabled property is truthy, and the other when it's false.

@levithomason levithomason changed the title fix(checkbox): applying disable attribute to input component if exists on Checkbox fix(checkbox): pass disabled prop to input May 18, 2018
@levithomason levithomason merged commit 0ea06ae into Semantic-Org:master May 18, 2018
@welcome
Copy link

welcome bot commented May 18, 2018

Congrats on merging your first pull request! 🎉🎉🎉

robot victory dance

@levithomason
Copy link
Member

Thank you so much!

@levithomason
Copy link
Member

Released in [email protected].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants