Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-13342: Fix dividers showing when menu section is empty. #2166

Closed
wants to merge 1 commit into from

Conversation

grundleborg
Copy link
Contributor

Summary

Fix dividers showing when menu section is empty.

This fix is a little ugly - it checks the children-of-children are not
null to work around connected components themselves not being null but
having the actual component within being null.

Ticket Link

https://mattermost.atlassian.net/browse/MM-13342

Checklist

  • Ran make check-style to check for style errors (required for all pull requests)
  • Ran make test to ensure unit and component tests passed
  • Added or updated unit tests (required for all new features)

This fix is a little ugly - it checks the children-of-children are not
null to work around connected components themselves not being null but
having the actual component within being null.
@grundleborg grundleborg added 2: Dev Review Requires review by a core commiter CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Dec 10, 2018
@grundleborg grundleborg added this to the v5.6.0 milestone Dec 10, 2018
@hmhealey
Copy link
Member

If you're wanting to avoid adding that extra introspection, perhaps we could actually fix this using CSS? If you look here, we already use .divider + .divider to hide the dividers for empty sections other than the first, so we can add .divider:firstChild to hide that first one as well.

@grundleborg
Copy link
Contributor Author

I don't think that will work, as we're not successfully hiding any of the dividers currently with the CSS. This fix targets all the unnecessary ones, not just the first one. Then again my CSS-foo isn't great so maybe I'm misunderstanding it?

@grundleborg
Copy link
Contributor Author

Sigh. Looks like this was a duplicate ticket anyway and Asaad has fixed it here #2152

@grundleborg grundleborg added the Do Not Merge Should not be merged until this label is removed label Dec 10, 2018
@hmhealey
Copy link
Member

I've merged and cherry picked that PR, so we could test again now to see if it's still an issue

Copy link
Collaborator

@cometkim cometkim left a comment

Choose a reason for hiding this comment

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

This is my mistake, obviously a composition-level.

If you change the actual markup and style to suit group composition, would be able to resolve the issue naturally without any CSS/Props hack.

@@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
const DropdownMenuItemGroup = ({children, showDivider = true}) => (
<React.Fragment>
{children}
{children.length && showDivider && (
{children.length && children.reduce((result, child) => (child && child.props.children && child.props.children.length) || result, false) && showDivider && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

children.every((child) => child?.props?.children?.length) is much better.

@grundleborg
Copy link
Contributor Author

Looks fixed to me now with Asaad's changes. Closing this PR.

@lindalumitchell lindalumitchell added the Tests/Not Needed Does not require new release tests label Dec 11, 2018
@hanzei hanzei removed the CherryPick/Approved Meant for the quality or patch release tracked in the milestone label Feb 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
2: Dev Review Requires review by a core commiter Do Not Merge Should not be merged until this label is removed Tests/Not Needed Does not require new release tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants