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(combobox): add space after grouped items #7302

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6573266
fix(combobox-item-group): add space after grouped items
Elijbet Jul 9, 2023
92c5695
nested groups padding visual
Elijbet Jul 9, 2023
6543cac
cleanup
Elijbet Jul 9, 2023
8740cfb
test is open
Elijbet Jul 9, 2023
c043c0c
Merge branch 'main' into elijbet/6412-combobox-item-group-add-space-a…
Elijbet Jul 11, 2023
1bc2915
merge files
Elijbet Jul 17, 2023
bd3532a
Merge branch 'main' into elijbet/6412-combobox-item-group-add-space-a…
Elijbet Jul 24, 2023
aab0b77
add more visual variation to nestedGroups testOnly story
Elijbet Jul 25, 2023
cbcfd6b
change of course: use css to target areas that require padding
Elijbet Jul 25, 2023
7a72ab7
Merge branch 'main' into elijbet/6412-combobox-item-group-add-space-a…
Elijbet Jul 25, 2023
4937d29
cleanup
Elijbet Jul 25, 2023
59dfba1
Merge branch 'main' into elijbet/6412-combobox-item-group-add-space-a…
Elijbet Aug 1, 2023
bae74f7
simplify complex css selector by adding class with the help of js
Elijbet Aug 1, 2023
4cf0d47
Merge branch 'main' into elijbet/6412-combobox-item-group-add-space-a…
Elijbet Aug 3, 2023
b937e93
since complex css selectors are giving issues with applying it to the…
Elijbet Aug 3, 2023
6030644
Merge branch 'main' into elijbet/6412-combobox-item-group-add-space-a…
Elijbet Aug 3, 2023
b5dae49
replace the attached css class with a new internal reflected prop
Elijbet Aug 3, 2023
92d3d01
tweak code to get all items to update when it runs
Elijbet Aug 3, 2023
85e7073
Merge branch 'main' into elijbet/6412-combobox-item-group-add-space-a…
Elijbet Aug 3, 2023
0ad516a
nestedGroups story is TestOnly
Elijbet Aug 3, 2023
9fb7fba
Merge branch 'main' into elijbet/6412-combobox-item-group-add-space-a…
Elijbet Aug 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(.group-that-follows-childless-group)) {
padding-block-start: var(--calcite-combobox-item-spacing-unit-l);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,31 @@ export const withSelectorIndicatorAndIcons_TestOnly = (): string => html`
</calcite-combobox>
`;

export const nestedGroups_TestOnly =
(): string => html`<calcite-combobox open selection-mode="single" style="width:400px" placeholder="Type to filter">
<calcite-combobox-item-group label="Level 1">
<calcite-combobox-item-group label="Level 2">
<calcite-combobox-item-group label="Level 3">
<calcite-combobox-item value="Item 1" text-label="Item 1">
</calcite-combobox-item>
<calcite-combobox-item value="Item 2" text-label="Item 2">
export const nestedGroups = (): string => html`
Elijbet marked this conversation as resolved.
Show resolved Hide resolved
<calcite-combobox label="test" placeholder="placeholder" max-items="10" scale="m" open>
<calcite-combobox-item-group label="First item group">
<calcite-combobox-item value="Pikachu" text-label="Pikachu"></calcite-combobox-item>
<calcite-combobox-item value="Charizard" text-label="Charizard"></calcite-combobox-item>

<calcite-combobox-item-group label="Cutest Pokémon">
<calcite-combobox-item value="Bulbasaur" text-label="Bulbasaur"></calcite-combobox-item>
<calcite-combobox-item-group label="No Pokémon 🙃"></calcite-combobox-item-group>

<calcite-combobox-item-group label="Cutest Pokémon">
<calcite-combobox-item value="Squirtle" text-label="Squirtle">
<calcite-combobox-item value="Charizard" text-label="Charizard"></calcite-combobox-item>
</calcite-combobox-item>
</calcite-combobox-item-group>
</calcite-combobox-item-group>
</calcite-combobox-item-group>

<calcite-combobox-item-group label="Last item group">
<calcite-combobox-item value="Squirtle" text-label="Squirtle">
<calcite-combobox-item value="Charizard" text-label="Charizard"></calcite-combobox-item>
</calcite-combobox-item>
</calcite-combobox-item-group>
</calcite-combobox>`;
</calcite-combobox>
`;

export const clearDisabled_TestOnly = (): string => html`
<calcite-combobox clear-disabled selection-mode="single" style="width:400px">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,15 @@ export class Combobox
if (!this.allowCustomValues) {
this.setMaxScrollerHeight();
}

this.groupItems.forEach((groupItem, index, array) => {
if (groupItem.children.length === 0) {
if (index + 1 < array.length) {
const nextGroupItem = array[index + 1];
nextGroupItem.classList.add(CSS.groupThatFollowsChildlessGroup);
Elijbet marked this conversation as resolved.
Show resolved Hide resolved
}
}
});
};

getData(): ItemData[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export const ComboboxChildSelector = `${ComboboxItem}, ${ComboboxItemGroup}`;

export const CSS = {
listContainer: "list-container",
groupThatFollowsChildlessGroup: "group-that-follows-childless-group",
};