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

fix(HierarchicalMenu): don't give --parent class if data is empty #5458

Merged
merged 2 commits into from
Jan 26, 2023

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Jan 26, 2023

Summary

This happens when the item is refined, but there's no items in the lower level. In InstantSearch.js and React InstantSearch Dom, we avoid adding the class in this case already:

Boolean(
isHierarchicalMenuItem(facetValue) &&
Array.isArray(facetValue.data) &&
facetValue.data.length > 0
) && this.props.cssClasses.parentItem!

const itemHasChildren = item.items && Boolean(item.items.length);
return (
<li
key={item.key || item.label}
className={this.props.cx(
'item',
item.isRefined && 'item--selected',
item.noRefinement && 'item--noRefinement',
itemHasChildren && 'item--parent'
)}
>

detected in #5456

Result

ais-HierarchicalMenu-item--parent is not applied when children are empty, even if it is refined. This makes React InstantSearch Hooks and Vue InstantSearch consistent with the other flavours.

@Haroenv Haroenv requested review from a team, sarahdayan and aymeric-giraudet and removed request for a team January 26, 2023 12:45
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 26, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f49f471:

Sandbox Source
InstantSearch.js Configuration
react-instantsearch-app Configuration

Copy link
Member

@dhayab dhayab left a comment

Choose a reason for hiding this comment

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

Could we amend our tests to cover this case?

@Haroenv Haroenv requested a review from dhayab January 26, 2023 13:27
@Haroenv Haroenv changed the title fix(HierarchicalMenu): don't give parentItem class if data is empty fix(HierarchicalMenu): don't give --parent class if data is empty Jan 26, 2023
@Haroenv Haroenv merged commit 1d1a209 into master Jan 26, 2023
@Haroenv Haroenv deleted the fix/hierarchical-parent-condition branch January 26, 2023 14:01
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.

2 participants