-
Notifications
You must be signed in to change notification settings - Fork 438
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: unset should unset readOnly date field from custom input component #8192
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
Component Testing Report Updated Jan 6, 2025 12:52 PM (UTC) ✅ All Tests Passed -- expand for details
|
⚡️ Editor Performance ReportUpdated Mon, 06 Jan 2025 12:55:53 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
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 works well from my PoV!
Tested with the following input component, on the same document in two different windows to check multiplayer as well.
components: {
input: function T(props: DateInputProps) {
const [ro, setRo] = useState(false)
return (
<Stack space={2}>
{props.renderDefault({...props, readOnly: ro})}
<Button
text={`Make ${ro ? 'writable' : 'readOnly'}`}
onClick={() => setRo((r) => !r)}
/>
<Button text={`Unset field`} onClick={() => props.onChange(unset())} />
<Button
text={`Set field`}
onClick={() => props.onChange(set(new Date().toISOString().split('T')[0]))}
/>
</Stack>
)
},
}
The input now updates in readonly mode.
Also tested datetime (without the split on the set button)
(TIL: we dont store the date input if it is not valid, so typing garbage in the filed does not sync)
Description
At the moment if you create a custom input component for a
datetime
field or adate
field, and performunset
in the custom input component when the field isreadOnly
the value will not update on the field.This occurs because this looks like it stores a local value, and when the field is read only, the input renders a plain text field which never triggers
handleDatePickerInputChange
.In this PR, I have removed the plain text field and used the propagated
readOnly
flag to instead achieve this in theDateTimeInput
componentWhat to review
We think this is ok? I'm not sure of the reasons for using the
Text
component instead but this feels better to allow theDateTimeInput
to be able to be read only, for usage in other scenarios too?Testing
Didn't add any tests for this, let me know if I should.
Notes for release
unset()
inside customdatetime
input
components will now shown the that the value has been unset in the Studio UI.