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(Input): replace disabled class with disabled attribute #1591

Merged
merged 5 commits into from
May 6, 2017

Conversation

dvdzkwsk
Copy link
Member

@dvdzkwsk dvdzkwsk commented Apr 17, 2017

Resolves #1565.

@levithomason This, ironically enough, is a matter of semantics. Your call here, but in my opinion this improves the functionality of inputs as they now receive an actual disabled attribute instead of relying on custom styling with a disabled class above the input element itself. This allows disabled inputs to inherit standard browser behavior and conform to general user expectations.

I checked it out in the docs and by removing the disabled class, the styles still look correct.

'multiple', 'name', 'pattern', 'placeholder', 'readOnly', 'required', 'step', 'type', 'value',

// Heads Up!
Copy link
Member Author

Choose a reason for hiding this comment

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

Handled this by not applying the disabled class. Potentially breaking change for users who relied on that as a CSS selector.

@codecov-io
Copy link

codecov-io commented Apr 17, 2017

Codecov Report

Merging #1591 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1591      +/-   ##
==========================================
+ Coverage   99.74%   99.75%   +<.01%     
==========================================
  Files         141      141              
  Lines        2398     2406       +8     
==========================================
+ Hits         2392     2400       +8     
  Misses          6        6
Impacted Files Coverage Δ
src/elements/Input/Input.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 c6f80cf...0cdeee1. Read the comment docs.

@levithomason
Copy link
Member

Per offline chats, let's keep both the top level className so child elements are disabled but also apply the attribute.

I'll PR the CSS to handle the double opacity issue.

@levithomason
Copy link
Member

Tracking Semantic-Org/Semantic-UI#5284

@levithomason
Copy link
Member

This seems to have broken tests for input shorthand prop (common).

@dvdzkwsk
Copy link
Member Author

dvdzkwsk commented Apr 25, 2017

SUI issue has no traction :(


if (disabled) htmlInputProps.disabled = disabled
if (onChange) htmlInputProps.onChange = this.handleChange
if (tabIndex) htmlInputProps.tabIndex = tabIndex
Copy link
Member

@layershifter layershifter Apr 25, 2017

Choose a reason for hiding this comment

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

The problem is that the component receives disabled as undefined, same is for tabIndex

I made tests working, however, it's not the best idea 💩 May be better solution possible there?

Copy link
Member

Choose a reason for hiding this comment

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

I believe if the disabled prop is undefined, then the htmlInputProps.disabled should also be undefined. Perhaps I'm overlooking the issue or use case here.

Copy link
Member

Choose a reason for hiding this comment

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

@levithomason You're right, but if we replace current code with:

if (onChange) htmlInputProps.onChange = this.handleChange

return [{...htmlInputProps, disabled, tabIndex}, rest]

But, we will have failing tests of shorhand.

Copy link
Member

Choose a reason for hiding this comment

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

However, we can fix this in test:

  common.implementsHTMLInputProp(Input, {
    alwaysPresent: true,
-    shorthandDefaultProps: { type: 'text' },
+    shorthandDefaultProps: { disabled: undefined, tabIndex: undefined, type: 'text' },
  })

May be I overlooked something?

@levithomason
Copy link
Member

Thanks for the updates @layershifter !

@levithomason
Copy link
Member

Released in semantic-ui-react@0.68.3.

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.

4 participants