-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix bug related to ticket #6703 placeholder not updating due to wrong… #7121
base: develop
Are you sure you want to change the base?
Conversation
Thanks for your interest in palantir/blueprint, @sc-mitton! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
Generate changelog in
|
@@ -373,6 +373,7 @@ export const DateInput3: React.FC<DateInput3Props> = React.memo(function _DateIn | |||
const handleInputBlur = React.useCallback( | |||
(e: React.FocusEvent<HTMLInputElement>) => { | |||
if (inputValue == null || valueAsDate == null) { | |||
setIsInputFocused(false); |
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.
This seems to fix the bug where a controlled prop passed to DateInput3 is set to a particular value, but it still seems to miss when the value is cleared, e.g.
Can we also handle that related case here?
I think it should be a matter of affecting one of the useEffects above to handle the case where valueFromProps
gets set to to a nullish value. Something like:
React.useEffect(() => {
if (isControlled || valueFromProps == null) {
setValue(valueFromProps);
}
}, [isControlled, valueFromProps]);
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.
const isControlled = valueFromProps !== undefined;
The isControlled variable is already defined as valueFromProps !== undefined. So isControlled || valueFromProps == null would be redundant no? If valueFromProps == null is true, then isControlled is already true.
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.
…to wrong focus state
… focus state
Fixes #6703
Fix a bug where the value isn't updating from controlled input.