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

feat: disable input #188

Merged
merged 7 commits into from Oct 23, 2018
Merged

feat: disable input #188

merged 7 commits into from Oct 23, 2018

Conversation

ghost
Copy link

@ghost ghost commented Oct 17, 2018

Fixes #187

I've had to update package.json to get the specific versions ava and babel, otherwise I couldn't get the tests to run properly. I've actually just checked this from PR186

disable search input and dropdown (no dropdown on click)
tests to cover new features
update storybook options

If there's anything i missed or need to do, please let me know.

@ghost ghost changed the title Feat/disable input feat: disable input Oct 17, 2018
@coveralls
Copy link

coveralls commented Oct 17, 2018

Coverage Status

Coverage increased (+0.05%) to 88.699% when pulling c74d0d5 on itrombitas:feat/disableInput into e670002 on dowjones:develop.

abatrinu
abatrinu previously approved these changes Oct 17, 2018
Copy link

@abatrinu abatrinu left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@mrchief mrchief left a comment

Choose a reason for hiding this comment

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

Thank you for submitting this PR. It is very well thought out, and updating the docs examples and updating bundle.js is a nice touch.

The package.json changes are fine. I recently spent a good deal of time upgrading to babel-7 and latest of ava and what not but I had multiple issues that were insurmountable. So until babel-7 gets mature, I think it's a good idea to pin these.

I have some suggestions. Please review and let me know your thoughts.

src/index.js Outdated
@@ -175,7 +179,7 @@ class DropdownTreeSelect extends Component {
render() {
const dropdownTriggerClassname = cx({
'dropdown-trigger': true,
arrow: true,
arrow: !this.props.disabled,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should leave the arrow as is but add another class disabled for disabled case. This accomplishes few things:

  • keeps the current behavior as is
  • the arrow should not disappear, rather appear as disabled for a better UX
  • allows users to extend or style differently when the control is disabled (since it's not a native control, they cannot use CSS attribute selector)

Also, I think we need some disabled styling for arrow like greying it out and setting cursor to not-allowed.

@@ -47,6 +48,7 @@ class Input extends PureComponent {
<li className={cx('tag-item')}>
<input
type="text"
disabled={this.props.disabled}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you move it to the props destructuring statement at the beginning - to keep things consistent?

const { ..., disabled, ...} = this.props
...
disabled={disabled}
...

src/index.js Outdated
@@ -84,6 +85,9 @@ class DropdownTreeSelect extends Component {

handleClick = () => {
this.setState(prevState => {
if (this.props.disabled) {
return { showDropdown: false }
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can save some unnecessary render cycles if we simply add a no-op click handler for disabled

<a className={dropdownTriggerClassname} onClick={!this.props.disabled && this.handleClick}>

@ghost
Copy link
Author

ghost commented Oct 18, 2018

Thanks for the feedback.
I've reviewed the changes you've requested and fully agree with them. Please have a look at the updated code.

Thanks

@mrchief
Copy link
Collaborator

mrchief commented Oct 18, 2018

Awesome! Changes look good on paper. I'll run this branch locally and if everything checks out, will merge it. Stay tuned!

mrchief
mrchief previously approved these changes Oct 23, 2018
Copy link
Collaborator

@mrchief mrchief left a comment

Choose a reason for hiding this comment

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

👍

@mrchief mrchief merged commit dbcd71e into dowjones:develop Oct 23, 2018
mrchief pushed a commit that referenced this pull request Oct 23, 2018
* chore: Update package.json dependencies

* feat: Add disabled prop to Input and DropdownTreeSelect

* chore: Rebuild bundle.js

* style: Show arrow as disabled, update disabled logic

* chore: Update docs

* chore: Make demo script easier to use
@mrchief
Copy link
Collaborator

mrchief commented Dec 6, 2018

🎉 This PR is included in version 1.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants