Skip to content

Make Slider a controlled component #1426

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

Merged
merged 10 commits into from
Jul 6, 2018

Conversation

dlferro
Copy link
Contributor

@dlferro dlferro commented Jun 19, 2018

Now sets the value attribute from props.value.

Fixes #1398


Pull Request Review checklist (do not remove)

  • npm run lint:fix has been run and linting passes.
  • Mocha, Jest (Storyshots), and components/component-docs.json CI tests pass (npm test).
  • Tests have been added for new props to prevent regressions in the future. See readme.
  • Review the appropriate Storybook stories. Open http://localhost:9001/.
  • The Accessibility panel of each Storybook story has 0 violations (aXe). Open http://localhost:9001/.
  • Review tests are passing in the browser. Open http://localhost:8001/.
  • Review markup conforms to SLDS by looking at DOM snapshot strings.
  • Add year-first date and commit SHA to last-slds-markup-review in package.json and push.
  • Request a review of the deployed Heroku app by the Salesforce UX Accessibility Team.
  • Add year-first review date, and commit SHA, last-accessibility-review, to package.json and push.
  • While the contributor's branch is checked out, run npm run local-update within locally cloned site repo to confirm the site will function correctly at the next release.

Now sets the value attribute from props.value.
@interactivellama interactivellama changed the title Fixes salesforce/design-system-react#1398 Make Slider a controlled component Jun 25, 2018
Make onChange callback provide a number, since a number is passed into value.
Make onChange callback provide a number, since a number is passed into value.
…react into DanFerro-slider-value-fix

# Conflicts:
#	components/slider/index.jsx
@interactivellama
Copy link
Contributor

@garygong This was the question I was asking about earlier that was whether a change to a component was a breaking change if the component did not work as intended in the first place.

@interactivellama interactivellama requested review from futuremint and removed request for garygong July 4, 2018 14:34
@interactivellama
Copy link
Contributor

Moving Review request to @futuremint if he is available this week.

@futuremint
Copy link
Contributor

I'm available and I'll review this today.

Copy link
Contributor

@futuremint futuremint left a comment

Choose a reason for hiding this comment

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

A change to consider and a question for some more context around one of the changes.

@@ -140,13 +139,13 @@ class Slider extends React.Component {

handleChange = (event) => {
if (isFunction(this.props.onChange)) {
this.props.onChange(event, { value: event.target.value });
this.props.onChange(event, { value: parseInt(event.target.value, 10) });
Copy link
Contributor

Choose a reason for hiding this comment

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

This could pose a problem should a user want to make a slider for floats (a slider between 0 and 1 for example). I'm not sure we want to have parseInt here because we can't assume.

Copy link
Contributor

@interactivellama interactivellama Jul 5, 2018

Choose a reason for hiding this comment

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

The input returns a text value, but we expect a number be passed in. I'll look into using Number().

@@ -400,7 +400,7 @@ const Dialog = createReactClass({
}

if (this.props.style) {
style = Object.assign(style, this.props.style);
style = { ...style, ...this.props.style };
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

/* eslint-enable max-len */
hasWarned[`${control}-path`] = !!url;
}
const warn = (control, url, comment) => (res) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to add support for fetch here? Does this address a maintenance issue in the backlog or something else?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, that's already in master. I'll remove it.

instead of parseInt in order to allow decimal values
@interactivellama
Copy link
Contributor

@futuremint

  • Fetch commit removed after pull from upstream.
  • parseInt replaced with Number()

@futuremint futuremint merged commit e18fff5 into salesforce:master Jul 6, 2018
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.

Slider: Allow value to be set
3 participants