diff --git a/packages/calcite-components/src/components/combobox-item-group/combobox-item-group.scss b/packages/calcite-components/src/components/combobox-item-group/combobox-item-group.scss index 65ec78890cc..dd6e2de9e8d 100644 --- a/packages/calcite-components/src/components/combobox-item-group/combobox-item-group.scss +++ b/packages/calcite-components/src/components/combobox-item-group/combobox-item-group.scss @@ -49,3 +49,7 @@ padding-inline: var(--calcite-combobox-item-spacing-unit-s); margin-inline-start: var(--calcite-combobox-item-indent-value); } + +::slotted(calcite-combobox-item-group:not([after-empty-group])) { + padding-block-start: var(--calcite-combobox-item-spacing-unit-l); +} diff --git a/packages/calcite-components/src/components/combobox-item-group/combobox-item-group.tsx b/packages/calcite-components/src/components/combobox-item-group/combobox-item-group.tsx index 6578f1fcb5e..d2d0dcca904 100644 --- a/packages/calcite-components/src/components/combobox-item-group/combobox-item-group.tsx +++ b/packages/calcite-components/src/components/combobox-item-group/combobox-item-group.tsx @@ -21,6 +21,13 @@ export class ComboboxItemGroup { // // -------------------------------------------------------------------------- + /** + * When `true`, signifies that the group comes after another group without any children (items or sub-groups), otherwise indicates that the group comes after another group that has children. Used for styling. + * + * @internal + */ + @Prop({ reflect: true }) afterEmptyGroup = false; + /** Specifies the parent and grandparent `calcite-combobox-item`s, which are set on `calcite-combobox`. */ @Prop({ mutable: true }) ancestors: ComboboxChildElement[]; diff --git a/packages/calcite-components/src/components/combobox/combobox.scss b/packages/calcite-components/src/components/combobox/combobox.scss index 0ef0c134e64..6d3bfbb7736 100644 --- a/packages/calcite-components/src/components/combobox/combobox.scss +++ b/packages/calcite-components/src/components/combobox/combobox.scss @@ -209,3 +209,7 @@ @include hidden-form-input(); @include base-component(); + +::slotted(calcite-combobox-item-group:not(:first-child)) { + padding-block-start: var(--calcite-combobox-item-spacing-unit-l); +} diff --git a/packages/calcite-components/src/components/combobox/combobox.stories.ts b/packages/calcite-components/src/components/combobox/combobox.stories.ts index 5c6b6a948e2..2daa9ef6b06 100644 --- a/packages/calcite-components/src/components/combobox/combobox.stories.ts +++ b/packages/calcite-components/src/components/combobox/combobox.stories.ts @@ -449,17 +449,31 @@ export const withSelectorIndicatorAndIcons_TestOnly = (): string => html` `; -export const nestedGroups_TestOnly = - (): string => html` - - - - - - +export const nestedGroups_TestOnly = (): string => html` + + + + + + + + + + + + + + + + + + + + -`; + +`; export const clearDisabled_TestOnly = (): string => html` diff --git a/packages/calcite-components/src/components/combobox/combobox.tsx b/packages/calcite-components/src/components/combobox/combobox.tsx index d80a63b2e0f..6fe2676744f 100644 --- a/packages/calcite-components/src/components/combobox/combobox.tsx +++ b/packages/calcite-components/src/components/combobox/combobox.tsx @@ -967,6 +967,18 @@ export class Combobox if (!this.allowCustomValues) { this.setMaxScrollerHeight(); } + + this.groupItems.forEach((groupItem, index, items) => { + if (index === 0) { + groupItem.afterEmptyGroup = false; + } + + const nextGroupItem = items[index + 1]; + + if (nextGroupItem) { + nextGroupItem.afterEmptyGroup = groupItem.children.length === 0; + } + }); }; getData(): ItemData[] {