@vaadin/field-base 24.9.1 → 24.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/field-base",
3
- "version": "24.9.1",
3
+ "version": "24.9.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,15 +32,15 @@
32
32
  "dependencies": {
33
33
  "@open-wc/dedupe-mixin": "^1.3.0",
34
34
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/a11y-base": "~24.9.1",
36
- "@vaadin/component-base": "~24.9.1",
35
+ "@vaadin/a11y-base": "~24.9.3",
36
+ "@vaadin/component-base": "~24.9.3",
37
37
  "lit": "^3.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@vaadin/chai-plugins": "~24.9.1",
41
- "@vaadin/test-runner-commands": "~24.9.1",
40
+ "@vaadin/chai-plugins": "~24.9.3",
41
+ "@vaadin/test-runner-commands": "~24.9.3",
42
42
  "@vaadin/testing-helpers": "^1.1.0",
43
43
  "sinon": "^18.0.0"
44
44
  },
45
- "gitHead": "b5b40f63cd1a8adef39be3adb02050082476ca7e"
45
+ "gitHead": "dbb4c450495cd72e3d8662119e96db60a89f86ea"
46
46
  }
@@ -3,6 +3,7 @@
3
3
  * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
+ import { isElementFocused } from '@vaadin/a11y-base/src/focus-utils.js';
6
7
  import { KeyboardMixin } from '@vaadin/a11y-base/src/keyboard-mixin.js';
7
8
  import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
8
9
  import { InputMixin } from './input-mixin.js';
@@ -71,7 +72,10 @@ export const ClearButtonMixin = (superclass) =>
71
72
  * @protected
72
73
  */
73
74
  _onClearButtonMouseDown(event) {
74
- event.preventDefault();
75
+ if (this._shouldKeepFocusOnClearMousedown()) {
76
+ event.preventDefault();
77
+ }
78
+
75
79
  if (!isTouch) {
76
80
  this.inputElement.focus();
77
81
  }
@@ -109,4 +113,17 @@ export const ClearButtonMixin = (superclass) =>
109
113
  this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
110
114
  this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
111
115
  }
116
+
117
+ /**
118
+ * Whether to keep focus inside the field on clear button
119
+ * mousedown. By default, if the field has focus, it gets
120
+ * preserved using `preventDefault()` on mousedown event
121
+ * in order to avoid blur and change events.
122
+ *
123
+ * @protected
124
+ * @return {boolean}
125
+ */
126
+ _shouldKeepFocusOnClearMousedown() {
127
+ return isElementFocused(this.inputElement);
128
+ }
112
129
  };