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: add missing CSS property for chip min-width #7861

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -147,6 +147,7 @@ export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap
* `--vaadin-field-default-width` | Default width of the field | `12em`
* `--vaadin-multi-select-combo-box-overlay-width` | Width of the overlay | `auto`
* `--vaadin-multi-select-combo-box-overlay-max-height` | Max height of the overlay | `65vh`
* `--vaadin-multi-select-combo-box-chip-min-width` | Min width of the chip | `50px`
* `--vaadin-multi-select-combo-box-input-min-width` | Min width of the input | `4em`
*
* ### Internal components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { css, registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixi
const multiSelectComboBox = css`
:host {
--input-min-width: var(--vaadin-multi-select-combo-box-input-min-width, 4em);
--_chip-min-width: var(--vaadin-multi-select-combo-box-chip-min-width, 50px);
}

[hidden] {
Expand Down Expand Up @@ -122,6 +123,7 @@ registerStyles('vaadin-multi-select-combo-box', [inputFieldShared, multiSelectCo
* `--vaadin-field-default-width` | Default width of the field | `12em`
* `--vaadin-multi-select-combo-box-overlay-width` | Width of the overlay | `auto`
* `--vaadin-multi-select-combo-box-overlay-max-height` | Max height of the overlay | `65vh`
* `--vaadin-multi-select-combo-box-chip-min-width` | Min width of the chip | `50px`
* `--vaadin-multi-select-combo-box-input-min-width` | Min width of the input | `4em`
*
* ### Internal components
Expand Down
23 changes: 23 additions & 0 deletions packages/multi-select-combo-box/test/chips.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,29 @@ describe('chips', () => {
await nextRender();
expect(overflow.hasAttribute('hidden')).to.be.true;
});

it('should always show at least one chip in addition to overflow', async () => {
comboBox.style.width = 'auto';
await nextResize(comboBox);
comboBox.selectedItems = ['apple', 'orange'];
await nextRender();
const chips = getChips(comboBox);
expect(chips.length).to.equal(2);
expect(getChipContent(chips[1])).to.equal('orange');
});

it('should set show max width on the chip based on CSS property', async () => {
comboBox.style.width = 'auto';
comboBox.clearButtonVisible = true;
await nextResize(comboBox);
comboBox.selectedItems = ['apple', 'orange'];
await nextRender();

const chips = getChips(comboBox);
const minWidth = getComputedStyle(comboBox).getPropertyValue('--_chip-min-width');
expect(minWidth).to.be.ok;
expect(chips[1].style.maxWidth).to.equal(minWidth);
});
});
});

Expand Down
Loading