-
Notifications
You must be signed in to change notification settings - Fork 80
fix(list-item): adds border between grouped and ungrouped list-items #8134
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
Changes from 4 commits
d3a5420
550a9fe
0ca9e21
cc38984
b616246
0127331
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,6 +360,8 @@ export class List implements InteractiveComponent, LoadableComponent, SortableCo | |
|
||
sortable: Sortable; | ||
|
||
private topLevelAncestorsMap = new Map<HTMLCalciteListItemElement, HTMLCalciteListItemElement>(); | ||
|
||
// -------------------------------------------------------------------------- | ||
// | ||
// Public Methods | ||
|
@@ -579,6 +581,10 @@ export class List implements InteractiveComponent, LoadableComponent, SortableCo | |
this.filterElements({ el: listItem, filteredItems, visibleParents }) | ||
); | ||
|
||
if (filteredItems.length > 0) { | ||
this.findAncestorOfFirstFilteredItem(filteredItems); | ||
} | ||
|
||
this.filteredItems = filteredItems; | ||
|
||
if (emit) { | ||
|
@@ -742,6 +748,51 @@ export class List implements InteractiveComponent, LoadableComponent, SortableCo | |
} | ||
}; | ||
|
||
private findAncestorOfFirstFilteredItem = (filteredItems: HTMLCalciteListItemElement[]): void => { | ||
if (this.topLevelAncestorsMap.size > 0) { | ||
this.topLevelAncestorsMap.forEach( | ||
(value: HTMLCalciteListItemElement, key: HTMLCalciteListItemElement) => { | ||
value.removeAttribute("data-filter"); | ||
key.removeAttribute("data-filter"); | ||
} | ||
); | ||
this.topLevelAncestorsMap.clear(); | ||
} | ||
|
||
filteredItems.forEach((item) => { | ||
if (item.hasAttribute("data-filter")) { | ||
item.removeAttribute("data-filter"); | ||
} | ||
}); | ||
|
||
const firstFilteredItem = filteredItems[0]; | ||
const topLevelAnchor = this.getTopLevelAncestorItemElement(firstFilteredItem); | ||
anveshmekala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (topLevelAnchor) { | ||
this.topLevelAncestorsMap.set(firstFilteredItem, topLevelAnchor); | ||
} | ||
|
||
filteredItems[0].setAttribute("data-filter", "0"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally missed this last time, but you can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we can rename the attribute to be something like |
||
this.topLevelAncestorsMap.get(filteredItems[0])?.setAttribute("data-filter", "0"); | ||
}; | ||
|
||
private getTopLevelAncestorItemElement = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you could use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per our convo, we can look at updating some of our |
||
el: HTMLCalciteListItemElement | ||
): HTMLCalciteListItemElement | null => { | ||
let closestParent = el.parentElement.closest("calcite-list-item") as HTMLCalciteListItemElement; | ||
anveshmekala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
while (closestParent) { | ||
const closestListItemAncestor = closestParent.parentElement.closest( | ||
"calcite-list-item" | ||
) as HTMLCalciteListItemElement; | ||
if (closestListItemAncestor) { | ||
closestParent = closestListItemAncestor; | ||
} else { | ||
return closestParent; | ||
} | ||
} | ||
return null; | ||
}; | ||
|
||
handleNudgeEvent(event: CustomEvent<HandleNudge>): void { | ||
const { direction } = event.detail; | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.