Skip to content
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 read-only variant #3054

Closed

Conversation

emyarod
Copy link
Member

@emyarod emyarod commented Jun 13, 2019

Closes #3018

Closes #1672

This PR adds read-only support to the text input and textarea components alongside a mechanism to convert the inputs to controlled mode based on the onChange handler and value prop. This PR also reimplements character counter (which was previously reverted but depends on the controlled/uncontrolled separation). Since controlled/uncontrolled separation itself doesn’t provide any benefit from user’s perspective until character counter is introduced, it is being introduced alongside the character counter feature here

Changelog

New

Testing / Reviewing

Ensure the read-only text input and character counters behave as expected

@netlify
Copy link

netlify bot commented Jun 13, 2019

Deploy preview for the-carbon-components ready!

Built with commit 5276b58

https://deploy-preview-3054--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Jun 13, 2019

Deploy preview for carbon-elements ready!

Built with commit 6faa37b

https://deploy-preview-3054--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Jun 13, 2019

Deploy preview for carbon-elements ready!

Built with commit 5276b58

https://deploy-preview-3054--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Jun 13, 2019

Deploy preview for carbon-components-react failed.

Built with commit 6faa37b

https://app.netlify.com/sites/carbon-components-react/deploys/5d025f43fcc7e3000743d743

@netlify
Copy link

netlify bot commented Jun 13, 2019

Deploy preview for carbon-components-react ready!

Built with commit c33c472

https://deploy-preview-3054--carbon-components-react.netlify.com

Copy link
Contributor

@shixiedesign shixiedesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall! A few small things:

  • clicking outside the tooltip should close the tooltip (vanilla only, react looks fine)
    Jun-19-2019 10-13-19
  • new tooltip should show above existing tooltip on screen, potentially not an issue if we can close the other tooltip easily
    Jun-19-2019 10-16-50
    image
  • Is it possible to disable "error state" on read-only? This situ shouldn't arise. It doesn't give user a way forward since field cannot be edited.
    image

@emyarod
Copy link
Member Author

emyarod commented Jun 20, 2019

clicking outside the tooltip should close the tooltip (vanilla only, react looks fine)

@shixiedesign clicking outside of the tooltip in both vanilla and react closes the tooltip for me. can you provide more details about how to reproduce this issue?

@emyarod emyarod force-pushed the 3018-read-only-text-input branch 2 times, most recently from 9148838 to 8ac2852 Compare June 20, 2019 18:45
@elizabethsjudd
Copy link
Contributor

@emyarod Depending on what version of the tooltip you are using it could be related to this question i had: #3099 (comment)

@emyarod
Copy link
Member Author

emyarod commented Jun 20, 2019

@elizabethsjudd this is using the WCAG 2.0 compliant tooltip. do you mean the behavior is inconsistent when a button is the trigger element?

@elizabethsjudd
Copy link
Contributor

@emyarod when a button is used as the trigger for a tooltip, the user can "click" on the button and the tooltip will remain active until the user clicks somewhere else (the button is given focus which also causes the tooltip to display). You can scroll, resize, mouse over other elements, etc all while the tooltip remains open (this is what I believe is causing the scenario @shixiedesign is pointing out by having two tooltips open at once). The one thing I don't know is if this is accurate behavior because in actual offerings we'd expect a button to perform an action which would most likely cause the focus to change/move and therefore I believe the tooltip would hide. The question that I'm bringing up however is that I feel like both of these tooltips seem like they should be "definition tooltips" as they are either explaining the reason something is in a state, or it's just the extended version of the inputs value. My question in the other issue is that I don't feel like "definition tooltips" should be clickable at all unless they are on a button that is actually performing another action. In this use-case I don't feel that the tooltips should be on clickable triggers and the clicking is what is making them persistent. I've done a ton of research and implementations of various types of a11y tooltips so if you have any questions around this don't hesitate to ask.

@emyarod
Copy link
Member Author

emyarod commented Jun 21, 2019

@elizabethsjudd that was intentional according to the initial component spec so that the user can select the content (although clicking on the read only input will also select all of the text). from what I understand, @shixiedesign is referring to clicking multiple times outside of the button before the tooltip closes, but I am unable to replicate that behavior (the tooltip is dismissed with one outside click for me). I think I need some clarification on what the bug report is referring to and some confirmation on the expected behavior

@elizabethsjudd
Copy link
Contributor

@emyarod thanks for the clarification. Just out of curiosity, are you using the first tooltip that's on this page: https://www.carbondesignsystem.com/components/tooltip/code? At least on the site demo even after I open the tooltip if I try to select the text the tooltip closes (because it closes by clicking anywhere outside the trigger). WH found this when we were working with tooltips and thought this was odd behavior. Is that an update that's also coming with this PR?

@emyarod
Copy link
Member Author

emyarod commented Jun 21, 2019

@elizabethsjudd, no I don't make any changes to the tooltip code in this PR so it seems you found a vanilla-only interactive tooltip bug. it looks like if I click on one of the interactive elements in the tooltip before trying to select the text the tooltip will not close (but only in the dev environment, not the Carbon website). probably need to examine the vanilla tooltip click handler. we can track this in a separate issue

@elizabethsjudd
Copy link
Contributor

@emyarod totally agree that it is out of scope for this issue. Thank you for confirming!

@elizabethsjudd
Copy link
Contributor

@emyarod I was just thinking about it. using aria-haspopup="true" would actually probably fix the "confusion" aspect that I was talking about earlier. Then the aria-controls applied dynamically should still allow JAWs users to toggle between the two when the the tooltip is open.

@emyarod
Copy link
Member Author

emyarod commented Jun 24, 2019

@elizabethsjudd just to confirm, aria-haspopup="true" would be persistent and aria-controls would be added depending on if the tooltip content is inserted in the DOM right?

also is this related to #3100?

@elizabethsjudd
Copy link
Contributor

@emyarod yes, and I would say that #3100 is related. I have a PR open for #3100 right now (see #3148). FYI though, #3148 only resolves AVT 1 issues. There are still issues with AVT 2 & 3 that I'm hoping to address next.

@emyarod
Copy link
Member Author

emyarod commented Jun 25, 2019

@shixiedesign I think this is good for another review before I port this over to React but I may hold off until #3148 and associated PRs are approved and merged

Copy link
Contributor

@shixiedesign shixiedesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@emyarod
Copy link
Member Author

emyarod commented Sep 16, 2019

depends on #3995 #4016

@jnm2377 jnm2377 removed their request for review September 17, 2019 15:07
@jnm2377
Copy link
Contributor

jnm2377 commented Sep 17, 2019

@emyarod can you explain how this is being blocked by #3986 ? It seems like that PR needs a bigger discussion, so I'm wondering how we can get this PR moving along. This is blocking another stale PR.

@jnm2377 jnm2377 removed the request for review from alisonjoseph September 17, 2019 15:13
@emyarod
Copy link
Member Author

emyarod commented Sep 17, 2019

@jnm2377 I am currently exploring ways to work around it

@joshblack
Copy link
Contributor

If we don't have a clear resolution in place, would be best to close this for now and revisit in our next components project 👍

@joshblack
Copy link
Contributor

Closing this since the stale warning label was applied >7 days ago 👍

Copy link
Contributor

@vpicone vpicone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use the :read-only pseudo-selector here rather than the attribute selector. Would likely only matter for folks overriding using the most "appropriate" selector.

Do we want to remove all the vanilla stuff from the PR?

@@ -80,7 +129,8 @@ storiesOf('TextInput', module)
() => (
<TextInput
type={select('Form control type (type)', types, 'text')}
{...props.TextInputProps()}
{...props.textInput()}
invalid={props.textInput().readOnly ? false : props.textInput().invalid}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work ignoring validation here, we definitely want to make sure that's the case in any readonly inputs

@emyarod emyarod deleted the 3018-read-only-text-input branch August 30, 2021 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read only text input [Text input] Add character limit/counter