Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[fields] Allow empty
textField
slot placeholder value #13148[fields] Allow empty
textField
slot placeholder value #13148Changes from 3 commits
a2bc2be
442c3ec
0543df6
658c29c
d9d4964
78007e0
622ee27
fd2ea8c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
How about simply doing:
I think that it would be more consistent with the other props in our codebase.
Usually when you pass
undefined
, we fallback to the internal value rather than applyingundefined
(for example inprops.value
orprops.views
)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.
My thought to decide to use this approach was to be able to differentiate the scenarios:
In both cases
inPlaceholder
will be undefined, but on the second scenario, we don't pass forward the prop, so theparams.forwardedProps.hasOwnProperty('placeholder')
will be false and it will fall on the default placeholder, on the other hand if users explicitly passes the prop as undefined, I assume they wish to have an empty placeholder. WDYT ?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 totally understand your approach
IMHO, we should render the default placeholder when the user renders
<DateField placeholder={undefined} />
, because it's closer from the other props / components behavior (<DateField minDate={undefined} />
will apply the 01-01-1900 as the min date rather than removing the boundary,<DateField value={undefined} />
will fallback to the internal state rather than enforcing an empty value, etc...).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 agree with @flaviendelangle on this one, let's go for simplicity. 👍
In "my book",
undefined
== no prop.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.
Thanks, folks. Done in 658c29c
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.
Have you tried testing Flavien's suggestion?
I think that with it we could remove the
?? ''
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.
And remove
params.forwardedProps
from the depsThere 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.
Oops 🙈
Done in d9d4964 and 78007e0
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 could force the placeholder to be recalculated more often than we'd want. 🙈