Skip to content

Commit

Permalink
fix(slider): add value to onBlur (#11348)
Browse files Browse the repository at this point in the history
* fix(slider): add value to onBlur

* chore(slider): test changes

* feat(slider): add value validity for on blur

* feat(slider): add value validity for on blur
  • Loading branch information
aledavila authored May 19, 2022
1 parent e81b7f0 commit 1952328
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/react/src/components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ export default class Slider extends PureComponent {
*/
name: PropTypes.string,

/**
* Provide an optional function to be called when the input element
* loses focus
*/
onBlur: PropTypes.func,

/**
* The callback to get notified of change in value.
*/
Expand Down Expand Up @@ -433,11 +439,13 @@ export default class Slider extends PureComponent {
if (!evt || !('target' in evt) || typeof evt.target.value !== 'string') {
return;
}

// determine validity of input change after clicking out of input
const validity = evt.target.checkValidity();
this.setState({
isValid: validity,
});
const { value } = evt.target;

this.setState({ isValid: validity });
this.props.onBlur({ value });
};

/**
Expand Down

0 comments on commit 1952328

Please sign in to comment.