-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Implement SpinButton onValidValueUpdated callback. #7577
Implement SpinButton onValidValueUpdated callback. #7577
Conversation
|
packages/office-ui-fabric-react/src/components/SpinButton/SpinButton.tsx
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/SpinButton/SpinButton.test.tsx
Outdated
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/SpinButton/SpinButton.test.tsx
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/SpinButton/SpinButton.tsx
Show resolved
Hide resolved
packages/office-ui-fabric-react/src/components/SpinButton/SpinButton.tsx
Outdated
Show resolved
Hide resolved
.../office-ui-fabric-react/src/components/SpinButton/examples/SpinButton.Controlled.Example.tsx
Outdated
Show resolved
Hide resolved
.../office-ui-fabric-react/src/components/SpinButton/examples/SpinButton.Controlled.Example.tsx
Show resolved
Hide resolved
* This callback is triggered after SpinButton normalized and validated the user input value. | ||
* @param value - The normalized and valid value in the input box. | ||
*/ | ||
onValidValueUpdated?: (value: string) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onValidValueUpdated?: (value: string) => void; [](start = 2, length = 46)
Should there be some information on how this should be used taking into account the onIncrement, onDecrement, and onValidate props? Also, how do those props and this one work together? If they don't work together in a sensible way there should be a warn mutually exclusive telling creators not to combine them (potentially as well as something in the documentation here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not really related. They work together great as the way they work. The onIncrement/onDecrement/onValidate is to inject some customized logic, the onValidValueUpdated is to listen on something happens. I think the doc here is completed, mention something unrelated is not wise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the callback naming onValidValueUpdated
is pretty complex and speaks to a lot of the architectural issues that SpinButton has (as discussed in #5326.) However, we do have an onValidate
, as well as callbacks that use past tense naming to imply an action occurred. Could this be more simply named onValidated
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JasonGore I am fine with any naming part. IMO, one difference of onValidValueUpdated
and onValidated
is do we want to trigger the callback after validated with the same value. Again, I am fine with both.
I totally agree that the name exposes the architectural issue of SpinButton. I could like to help if we have a clear direction on goal. Could you please like to provide your ideas/suggestions to my questions here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jspurlin Thank you very much for helping reviewing the changes! @ecraig12345 Could you please help on taking a look? |
I'm a bit concerned with the naming here. Are we making this component more complicated than it needs to be? |
What I mean: I expect to make a controlled version of this component like an input element: I render using value The user clicks up arrow The The user gets the new value and rerenders, or, the user ignores the update and nothing changes. Why do we need any more complexity than this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's hold and discuss this internally first.
@dzearing The behavior of If we have a clear view about how |
@lijunle when you're back, let's reconvene on this issue. Closing the PR for now. |
Pull request checklist
$ npm run change
Description of changes
Implement
SpinButton
'sonValidValueUpdated
callback to notify the parent to control the component..Focus areas to test
SpinButton
component.Microsoft Reviewers: Open in CodeFlow