-
Notifications
You must be signed in to change notification settings - Fork 1.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
feat(text-input): add readonly variant #8806
feat(text-input): add readonly variant #8806
Conversation
✔️ Deploy Preview for carbon-elements ready! 🔨 Explore the source changes: f2d8a50 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/60b5050a3cf4fd00075c164e 😎 Browse the preview: https://deploy-preview-8806--carbon-elements.netlify.app |
✔️ Deploy Preview for carbon-elements ready! 🔨 Explore the source changes: 64b2ccb 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/60cb6c6b136f2800080e202c 😎 Browse the preview: https://deploy-preview-8806--carbon-elements.netlify.app |
✔️ Deploy Preview for carbon-components-react ready! 🔨 Explore the source changes: f2d8a50 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/60b5050ab60b2400078d33c8 😎 Browse the preview: https://deploy-preview-8806--carbon-components-react.netlify.app/iframe |
✔️ Deploy Preview for carbon-components-react ready! 🔨 Explore the source changes: 64b2ccb 🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/60cb6c6bfe17a100081396d4 😎 Browse the preview: https://deploy-preview-8806--carbon-components-react.netlify.app/iframe |
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.
Read-only appears to take precedence over warn and invalid. Was that the intended outcome?
Also, the stuff below.
Co-authored-by: Scott Strubberg <sstrubberg@protonmail.com>
@sstrubberg Yes, when
|
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 { prefix } = settings; | ||
|
||
export function useNormalizedInputProps({ |
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 this is a good point of abstraction. Could you add a jsdoc-type comment for it so we have some context on what this hook accomplishes, when it should be used, expected param types, 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.
Pushed an update adding some guidance aorund it. Let me know what you think of it!
@tay1orjones Actually, now that you bring it up: |
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.
If read only takes precedence over disabled being applied, it looks fine visually. But if you think of a use case where a disabled read-only would be used, I would make the icon the same color as the disabled text like Taylor said. Let me know what you decide and I’ll approve.
@janhassel I don't see the |
@johnbister My plan would be to add support for |
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.
lgtm!
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.
lgtm!
@tay1orjones Regarding the |
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 for the follow up @janhassel , sounds good 👍
Ref #2177, #3018, #3054
Adds a readonly variant to the TextInput component.
Intentional differences from the original design spec:
EditOff16
icontooltipAlignment
,tooltipPosition
) and might introduce accessiblity issues that are to be addressed with the tooltip changes in v11.Changelog
New
props.readonly
onTextInput
Testing / Reviewing
readonly
attribute is set to<input>
accordinglyinvalid
,warn
,readonly
on both theTextInput
and thePasswordInput
componentSide note: this PR also adds a helper
useNormalizedInputProps
which aims to reduce some of the many conditional renderings that were introduced over time (e.g.{!invalid && !warn && !isFluid && !inline && helper}
) by outsourcing them and providing a single entry for the icons and validation messages.The intent is to add readonly support to other inputs as well (like
NumberInput
). This utility should help there as well and streamline the inputs. Let me know what you think!