Skip to content

Commit

Permalink
Revert docs and Storybook changes about target.visibility potential…
Browse files Browse the repository at this point in the history
…ly not being defined
  • Loading branch information
ciampo committed Mar 17, 2022
1 parent 43ff576 commit dad09a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/number-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ The callback receives two arguments:
1. `newValue`: the new value of the input
2. `extra`: an object containing, under the `event` key, the original browser event.

Note that the value received as the first argument of the callback is _not_ guaranteed to be a valid value (e.g. it could be outside of the range defined by the [`min`, `max`] props, or it could not match the `step`). In order to check the value's validity, check the `event.target?.validity.valid` property from the callback's second argument (_note: given how the component works internally, the `validity` property is not guaranteed to always be defined on `event.target`. When the `validity` property is not defined, you can assume the value received as valid_).
Note that the value received as the first argument of the callback is _not_ guaranteed to be a valid value (e.g. it could be outside of the range defined by the [`min`, `max`] props, or it could not match the `step`). In order to check the value's validity, check the `event.target?.validity.valid` property from the callback's second argument.

- Type: `(newValue, extra) => void`
- Required: No
Expand Down
8 changes: 1 addition & 7 deletions packages/components/src/number-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ function Example() {
value={ value }
onChange={ ( v, extra ) => {
setValue( v );
// Given how the component works internally, the `validity` property
// is not guaranteed to always be defined on `event.target`. When the
// `validity` property is not defined, you can assume the value
// received as valid.
setIsValidValue(
extra.event.target.validity?.valid ?? true
);
setIsValidValue( extra.event.target.validity.valid );
} }
/>
<p>Is valid? { isValidValue ? 'Yes' : 'No' }</p>
Expand Down

0 comments on commit dad09a5

Please sign in to comment.