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

Add titleView to SelectMenu #477

Merged
merged 11 commits into from
Jan 24, 2019
Merged

Add titleView to SelectMenu #477

merged 11 commits into from
Jan 24, 2019

Conversation

notfelineit
Copy link
Contributor

@notfelineit notfelineit commented Jan 18, 2019

This PR:

  • Fixes onFilterChange warning in the console
  • Adds an optional tooltip ? icon option to the SelectMenu header. (Needed for some Protocols UI work)

selectmenu

If this seems to specialized, and we should instead pass a render function for the header (or something else!) let me know :-)

@mshwery
Copy link
Contributor

mshwery commented Jan 18, 2019

Hey @notfelineit !

I think it might be better to provide a header render function. Tooltip in the header might be a fairly common use-case, but it also might be border-line too custom like you said. Thoughts?

@vadimdemedes @Rowno ?

@vadimdemedes
Copy link
Contributor

I think this may be too small of a change to trigger such major addition as header render function.

What do you think about removing tooltip in favor of putting text below the header? Reason I'm suggesting this is to avoid 2 popovers at the same time (select menu and tooltip).

cleanshot 2019-01-18 at 19 53 21 2x

Either way, I'm good with this change 👍

hasFilter,
close,
title,
tooltipContent,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you rename this prop to tooltip, so that it matches hasTooltip prop naming?

@notfelineit
Copy link
Contributor Author

@vadimdemedes That's a good idea! Will it work with really long helper text?

@mshwery
Copy link
Contributor

mshwery commented Jan 18, 2019

Really long text probably doesn't belong in tooltips either. That's usually an indicator that you should be using a different pattern. Most of the time tooltips are short phrases.

@notfelineit
Copy link
Contributor Author

@mshwery I agree 🤔 Before the tooltip, I had a subtitle (like Vadim's suggestion) with the following: To create a new tag type a key:value format into the search field. But that wrapped and made the title wonky, hence the tooltip. Do you guys have any suggestions on how else to surface this to users within the SelectMenu? Maybe as a detailPane?

detailView,
emptyView,
headerHeight,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we provide a default value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absorootintootinly

@notfelineit notfelineit changed the title Add tooltip to header in SelectMenu Add titleView to SelectMenu Jan 19, 2019
Copy link
Contributor

@mshwery mshwery left a comment

Choose a reason for hiding this comment

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

This looks good, but I'd recommend moving these changes into the component that actually uses them.

/>
</Pane>
)}
{hasTitle && titleView}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I think we should provide the below (removed) jsx as the default prop value for titleView. That way consumers of this component can continue using it as is.

The way you've moved the code around makes this a breaking change, technically.

@@ -128,6 +138,40 @@ export default class SelectMenu extends PureComponent {
return {}
}

getTitleView = (close, title, headerHeight, titleView) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could get rid of this code in favor pushing it into the component that actually uses titleView instead.

@notfelineit
Copy link
Contributor Author

@mshwery was that what you meant?

@@ -36,26 +42,48 @@ export default class SelectMenuContent extends PureComponent {
static defaultProps = {
options: [],
hasTitle: true,
hasFilter: true
hasFilter: true,
titleView: ({ close, title, headerHeight }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I would pull this out into a separate component so the defaultProps are easier to scan.

But this is exactly what I was thinking of!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoo! ok, I'll do that.

@notfelineit notfelineit merged commit 1938927 into master Jan 24, 2019
@notfelineit notfelineit deleted the franny/fix-SelectMenu branch January 24, 2019 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants