Add FieldLevelHelp component - #179
jeff-phillips-18 merged 16 commits into
Conversation
|
@AparnaKarve glad to see your first contribution here! |
serenamarie125
left a comment
There was a problem hiding this comment.
@AparnaKarve couple comments re: UX review
#1 - can you change the placement of the popover so it "points" at the "I" icon as shown here in the design: http://www.patternfly.org/pattern-library/forms-and-controls/help-on-forms/#design
#2 - per the design, I think we only support with popover, not tooltip - @jgiardino what do you think? should we remove the tooltip option to be inline with the documentation and ensure consistency?
#3 - this is a nit, but wondering if you could change the example to bring up a new tab when the link in the popover is clicked ? That would be the desired behavior, so if it's easy to change it may be worth it
|
Adding an action log for the link might be a better choice than adding a tab. Just my $00.02 |
| > | ||
| <label> | ||
| {children + ' '} | ||
| <Icon type="pf" name={'info'} style={{ color: '#0088ce' }} /> |
There was a problem hiding this comment.
we shouldn't use an inline style here add the btn-link class instead.
|
Hi @AparnaKarve , It will be better if you enable KNOBS panel to change "placement" or "trigger" properties 😊 |
|
and please add tests :-) |
a33fc90 to
12fe00e
Compare
This is done. Can you please check the storybook again.
Let me know what we decide. IMO, tooltips are nice to have.
Addressed the above. |
The link is inside the popover. Not sure how to get the clicking action output in the action log. |
12fe00e to
aeb861d
Compare
|
@ohadlevy I have added some tests that pass in my environment - but seem to fail on Travis. Not sure what the below CI error means - Did I miss something? |
|
Tests in this PR seem to be failing because of the snapshot files. In the travis configuration, do we need to delete the snapshot files prior to I managed to recreate the CI failure locally, and it looks like running |
|
@AparnaKarve you simply need to include the snapshot file too |
aeb861d to
fae5b63
Compare
|
Thanks @ohadlevy - that fixed it. |
|
I would agree that this particular component only be onClick per the design at http://www.patternfly.org/pattern-library/forms-and-controls/help-on-forms/#design Tooltips are useful, but I think we want this component to follow the design to maintain consistency across applications using this. |
ohadlevy
left a comment
There was a problem hiding this comment.
thanks @AparnaKarve I've left a few comments inline
|
|
||
| return ( | ||
| <div> | ||
| <label>{children + ' '}</label> |
There was a problem hiding this comment.
nitpick: please write as:
<label>{`${children} `}</label>| contentType === 'popover' ? ( | ||
| <Popover id="{contentType}">{htmlContent}</Popover> | ||
| ) : ( | ||
| <Tooltip id="{contentType}">{htmlContent}</Tooltip> |
There was a problem hiding this comment.
👍 to removing tooltip here, its not part of the pf-design.
There was a problem hiding this comment.
Not removing the tooltip option in this iteration.
Keeping it temporarily for demo purposes, to explain an issue related to Formgroups and Popover below - #179 (comment)
| import { defaultTemplate } from '../../../storybook/decorators/storyTemplates'; | ||
| import { DOCUMENTATION_URL } from '../../../storybook/constants'; | ||
| import { FieldLevelHelp } from './index'; | ||
|
|
There was a problem hiding this comment.
maybe we should add it under the forms stories? it makes sense to me to see a complete form with field level help instead of a standalone?
There was a problem hiding this comment.
In 6c9f1d2, I have added the story under Forms.
It was a good call to add the FieldLevelHelp use case in the Form, since it looks like I may have stumbled upon a bug in the Popover (or OverlayTrigger) component.
When the Popover component is used in conjunction with the FormGroup component, the Formgroup component steals the focus from Popover, causing the popover to close immediately. This happens in a fraction of a second, giving a visual impression that the popover never opened.
Please see a demo of the above issue here -
under the Forms->Horizontal Form->Phone field
For this particular use case, a workaround would be to keep the Popover open - (An option that you requested here - #179 (comment)). That way, we would at least see the popover contents.
The 'Close Popover' knob demonstrates the above (set the value to false)
The other workaround is to use Tooltips - but since we are not considering tooltips for the FieldLevelHelp component, that is probably not an option.
The 'Popover/Tooltip' knob demonstrates the above (set the value to 'tooltip')
| <FieldLevelHelp id="fieldlevelname1">Port Number</FieldLevelHelp> | ||
| ); | ||
|
|
||
| let tree = component.toJSON(); |
There was a problem hiding this comment.
I assume you can use const here?
| /** Contents displayed with popover or tooltip */ | ||
| content: PropTypes.string, | ||
| /** children nodes */ | ||
| children: PropTypes.node |
There was a problem hiding this comment.
does it make sense to have a props to force the popover to be open? (instead on just on hover/click)
There was a problem hiding this comment.
Added a new prop - close, to close/open the popover if the use case needs it.
(if popover is forced to be open, it can be closed after clicking on the 'i' icon)
|
Thanks for adding this @AparnaKarve! I also agree that this should only include the popover, and not the tooltip, to be consistent with the patternfly design documentation. The only issue I see is with keyboard accessibility. I should be able to use the Tab key to place focus on the element that triggers the popover, and the Enter key to toggle the popover. Currently, the help icon is implemented as a Also, how does this component fit in with the Forms component that currently exists? For example, will I be able to use the Forms component and include this FieldLevelHelp component? Or is additional work needed for either component to support this? And should we include a storybook that shows an example that uses both components? (We can create separate issues to track this work) |
|
@jgiardino Thanks for the above feedback. These are the most recent changes -
Let me know if you find anything else. Thanks. |
| > | ||
| <Button | ||
| bsStyle="link" | ||
| style={{ textDecoration: 'none', outline: 'none' }} |
There was a problem hiding this comment.
Can we remove these styles? Removing the outline results in an accessibility issue, because focus is not obvious to the sighted user who uses a keyboard to navigate.
Also, as a general rule, if styles are ever needed, chances are they should be added to the core patternfly repo so that all JS repos can benefit from them. There are probably rare cases where react has a unique case that exists only in the context of the react repo. In that case we would add .less and .scss files for the component. I just now opened PR #195 to the contributing guide that includes some of these updates, in case you want to review and provide feedback :-)
|
Yay, I'm glad using the button solved another issue. That was a happy accident! I made a comment inline about inline styles. Related to this, I do realize that when the outline is visible, it's right up next to the text which is a little odd. But since there is no html implementation of this pattern in patternfly core that provides an example for us to follow, then I think for now what you have (after you remove the inline styles) is fine. I created an issue in patternfly to capture this: patternfly/patternfly#943 Thank you for updating the Form examples to show the inline help. When I was looking at the html for this example, I noticed some weirdness. The elements |
580ffd8 to
48995b8
Compare
|
@jgiardino I have removed the inline styling and have also addressed the html weirdness from the form stories #179 (comment) |
|
@jeff-phillips-18, maybe it should just not implemented as a button? I think using a link, or just an icon can solve it without changing the styles (maybe just change the mouse pointer). |
@sharvit My initial approach to this was just using an icon, but that had it's own set of issues. The other issue with the icon approach is what @jgiardino mentioned above, about keyboard accessibility. |
|
Using Regarding @jeff-phillips-18 suggestion, I'm fine with adding css to the pf-react repo to address the outline issue until pf core has an implementation that we can use. I would suggest something like this: With the button getting the class: I pinged the css-ers under the patternfly group on slack for feedback about this too, so I may edit this in the near future if I get an alternate suggestion from them. |
|
one other thing i just now saw... your first commit needs to have commitizen syntax... so something like: |
Also extracted out label from the component Adjusted Story and Tests accordingly
Also, displayed label independently and not as part of the FieldLevelHelp component
Styling to be addressed in patternfly/patternfly#943
keep the `dangerouslySetInnerHTML` usage confined to the stories
f5628db
3f1a033 to
f5628db
Compare
|
@priley86 I have reworded the first commit as you have indicated above. |
|
great job @AparnaKarve ... this looks great to me. |
Pull Request Test Coverage Report for Build 697
💛 - Coveralls |
1 similar comment
Pull Request Test Coverage Report for Build 697
💛 - Coveralls |
|
woohoo 100% @AparnaKarve ! 🎉 🎉 thanks! |
|
Thanks everyone for your valuable feedback! |


Added a new component called
FieldLevelHelpbased on the design requirements in http://www.patternfly.org/pattern-library/forms-and-controls/help-on-forms/FieldLevelHelp Storybook
Fixes #115