Skip to content

Commit cab4a22

Browse files
sissbrueckerclaude
andauthored
fix: only open multi-select-combo-box dropdown on label or field click (CP: 25.2) (#12766)
This PR cherry-picks changes from the original PR #12739 to branch 25.2. --- > ## Description > > Depends on #12744 > > `ComboBoxBaseMixin._onHostClick()` opens the dropdown on any click that reaches the host. Combo-box and time-picker each override it to open only when the click lands on the label or the input field. Multi-select-combo-box never added that override, so clicking its helper text or its error message opened the dropdown. > > - Added a `_onHostClick()` override that opens only when the click path includes the label or the input field > - Added the two `opening disallowed` tests that combo-box and time-picker already have, under the same names > > The override lives in the mixin, next to where `_inputField` is resolved, matching time-picker. Chips keep opening the dropdown because they are slotted inside the input field element, so this does not change how they behave. > > ## Type of change > > - Bugfix > > ## How to test > > 1. Open `dev/multi-select-combo-box.html` > 2. Click the helper text below the field > 3. The dropdown stays closed > 4. Click the label, then the input field > 5. The dropdown opens in both cases > > 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 76c8c00 commit cab4a22

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎packages/multi-select-combo-box/src/vaadin-multi-select-combo-box-mixin.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,21 @@ export const MultiSelectComboBoxMixin = (superClass) =>
450450
});
451451
}
452452

453+
/**
454+
* Override method from `ComboBoxBaseMixin` to only open the dropdown
455+
* when clicking on the label or the input field.
456+
* @param {Event} event
457+
* @protected
458+
* @override
459+
*/
460+
_onHostClick(event) {
461+
const path = event.composedPath();
462+
463+
if (path.includes(this._labelNode) || path.includes(this._inputField)) {
464+
super._onHostClick(event);
465+
}
466+
}
467+
453468
/**
454469
* Override method from `ComboBoxBaseMixin` to implement clearing logic.
455470
* @protected

‎packages/multi-select-combo-box/test/overlay-opening.test.js‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@vaadin/chai-plugins';
2-
import { arrowDownKeyDown, arrowUpKeyDown, click, fixtureSync, nextRender } from '@vaadin/testing-helpers';
2+
import { arrowDownKeyDown, arrowUpKeyDown, click, fixtureSync, nextRender, nextUpdate } from '@vaadin/testing-helpers';
33
import '../src/vaadin-multi-select-combo-box.js';
44
import { getChips } from './helpers.js';
55
import { setInputValue } from './helpers.js';
@@ -159,6 +159,23 @@ describe('overlay opening', () => {
159159
});
160160

161161
describe('opening disallowed', () => {
162+
it('should not open on helper element click', async () => {
163+
comboBox.helperText = 'Helper Text';
164+
await nextUpdate(comboBox);
165+
comboBox.querySelector('[slot=helper]').click();
166+
167+
expect(comboBox.opened).to.be.false;
168+
});
169+
170+
it('should not open on error message element click', () => {
171+
comboBox.invalid = true;
172+
comboBox.errorMessage = 'Error message';
173+
174+
comboBox.querySelector('[slot=error-message]').click();
175+
176+
expect(comboBox.opened).to.be.false;
177+
});
178+
162179
it('should not open overlay when disabled is set to true', () => {
163180
comboBox.disabled = true;
164181
comboBox.open();

0 commit comments

Comments
 (0)