Skip to content

Commit a26ba6e

Browse files
authored
refactor: simplify input element logic in ComboBoxMixin (#9291)
1 parent 5b47137 commit a26ba6e

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

packages/combo-box/src/vaadin-combo-box-mixin.js

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -316,26 +316,14 @@ export const ComboBoxMixin = (subclass) =>
316316
return 'vaadin-combo-box';
317317
}
318318

319-
/**
320-
* Get a reference to the native `<input>` element.
321-
* Override to provide a custom input.
322-
* @protected
323-
* @return {HTMLInputElement | undefined}
324-
*/
325-
get _nativeInput() {
326-
return this.inputElement;
327-
}
328-
329319
/**
330320
* Override method inherited from `InputMixin`
331321
* to customize the input element.
332322
* @protected
333323
* @override
334324
*/
335-
_inputElementChanged(inputElement) {
336-
super._inputElementChanged(inputElement);
337-
338-
const input = this._nativeInput;
325+
_inputElementChanged(input) {
326+
super._inputElementChanged(input);
339327

340328
if (input) {
341329
input.autocomplete = 'off';
@@ -352,10 +340,6 @@ export const ComboBoxMixin = (subclass) =>
352340
input.setAttribute('autocorrect', 'off');
353341

354342
this._revertInputValueToValue();
355-
356-
if (this.clearElement) {
357-
this.clearElement.addEventListener('mousedown', this._boundOnClearButtonMouseDown);
358-
}
359343
}
360344
}
361345

@@ -371,6 +355,10 @@ export const ComboBoxMixin = (subclass) =>
371355
this.addEventListener('click', this._boundOnClick);
372356
this.addEventListener('touchend', this._boundOnTouchend);
373357

358+
if (this.clearElement) {
359+
this.clearElement.addEventListener('mousedown', this._boundOnClearButtonMouseDown);
360+
}
361+
374362
const bringToFrontListener = () => {
375363
requestAnimationFrame(() => {
376364
this._overlayElement.bringToFront();
@@ -557,7 +545,7 @@ export const ComboBoxMixin = (subclass) =>
557545

558546
/** @private */
559547
_updateActiveDescendant(index) {
560-
const input = this._nativeInput;
548+
const input = this.inputElement;
561549
if (!input) {
562550
return;
563551
}
@@ -589,7 +577,7 @@ export const ComboBoxMixin = (subclass) =>
589577
this._onClosed();
590578
}
591579

592-
const input = this._nativeInput;
580+
const input = this.inputElement;
593581
if (input) {
594582
input.setAttribute('aria-expanded', !!opened);
595583

0 commit comments

Comments
 (0)