@vaadin/field-base 22.0.1 → 22.0.2

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": "22.0.1",
3
+ "version": "22.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@open-wc/dedupe-mixin": "^1.3.0",
33
33
  "@polymer/polymer": "^3.0.0",
34
- "@vaadin/component-base": "^22.0.1",
34
+ "@vaadin/component-base": "^22.0.2",
35
35
  "lit": "^2.0.0"
36
36
  },
37
37
  "devDependencies": {
@@ -39,5 +39,5 @@
39
39
  "@vaadin/testing-helpers": "^0.3.2",
40
40
  "sinon": "^9.2.1"
41
41
  },
42
- "gitHead": "2b0a2bff0369d6020f7cc33ad35506aa2d1f6f68"
42
+ "gitHead": "df21370c4a655a38eac11f79686021ab3b0887ad"
43
43
  }
@@ -369,12 +369,18 @@ export const FieldMixin = (superclass) =>
369
369
  * @protected
370
370
  */
371
371
  _invalidChanged(invalid) {
372
- // Error message ID needs to be dynamically added / removed based on the validity
373
- // Otherwise assistive technologies would announce the error, even if we hide it.
374
- if (invalid) {
375
- this._fieldAriaController.setErrorId(this._errorId);
376
- } else {
377
- this._fieldAriaController.setErrorId(null);
378
- }
372
+ // This timeout is needed to prevent NVDA from announcing the error message twice:
373
+ // 1. Once adding the `[role=alert]` attribute by the `_updateErrorMessage` method (OK).
374
+ // 2. Once linking the error ID with the ARIA target here (unwanted).
375
+ // Related issue: https://github.com/vaadin/web-components/issues/3061.
376
+ setTimeout(() => {
377
+ // Error message ID needs to be dynamically added / removed based on the validity
378
+ // Otherwise assistive technologies would announce the error, even if we hide it.
379
+ if (invalid) {
380
+ this._fieldAriaController.setErrorId(this._errorId);
381
+ } else {
382
+ this._fieldAriaController.setErrorId(null);
383
+ }
384
+ });
379
385
  }
380
386
  };
@@ -3,9 +3,9 @@
3
3
  * Copyright (c) 2021 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { SlotController } from './slot-controller.js';
6
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
7
7
 
8
8
  /**
9
9
  * A controller to create and initialize slotted `<input>` element.
10
10
  */
11
- export class InputController implements SlotController {}
11
+ export class InputController extends SlotController {}
@@ -3,14 +3,15 @@
3
3
  * Copyright (c) 2021 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { SlotController } from './slot-controller.js';
6
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
7
7
 
8
8
  /**
9
9
  * A controller to create and initialize slotted `<input>` element.
10
10
  */
11
11
  export class InputController extends SlotController {
12
12
  constructor(host, callback) {
13
- super(host, [
13
+ super(
14
+ host,
14
15
  'input',
15
16
  () => document.createElement('input'),
16
17
  (host, node) => {
@@ -30,6 +31,6 @@ export class InputController extends SlotController {
30
31
  callback(node);
31
32
  }
32
33
  }
33
- ]);
34
+ );
34
35
  }
35
36
  }
@@ -3,9 +3,9 @@
3
3
  * Copyright (c) 2021 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { SlotController } from './slot-controller.js';
6
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
7
7
 
8
8
  /**
9
9
  * A controller to create and initialize slotted `<textarea>` element.
10
10
  */
11
- export class TextAreaController implements SlotController {}
11
+ export class TextAreaController extends SlotController {}
@@ -3,14 +3,15 @@
3
3
  * Copyright (c) 2021 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { SlotController } from './slot-controller.js';
6
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
7
7
 
8
8
  /**
9
9
  * A controller to create and initialize slotted `<textarea>` element.
10
10
  */
11
11
  export class TextAreaController extends SlotController {
12
12
  constructor(host, callback) {
13
- super(host, [
13
+ super(
14
+ host,
14
15
  'textarea',
15
16
  () => document.createElement('textarea'),
16
17
  (host, node) => {
@@ -33,6 +34,6 @@ export class TextAreaController extends SlotController {
33
34
  callback(node);
34
35
  }
35
36
  }
36
- ]);
37
+ );
37
38
  }
38
39
  }
@@ -1,8 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { ReactiveController } from 'lit';
7
-
8
- export class SlotController implements ReactiveController {}
@@ -1,36 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- export class SlotController {
7
- constructor(host, [slotName, slotFactory, slotInitializer]) {
8
- this.host = host;
9
- this.slotName = slotName;
10
- this.slotFactory = slotFactory;
11
- this.slotInitializer = slotInitializer;
12
- }
13
-
14
- hostConnected() {
15
- if (!this.__initialized) {
16
- const { host, slotName, slotFactory } = this;
17
-
18
- const slotted = host.querySelector(`[slot=${slotName}]`);
19
-
20
- if (!slotted) {
21
- const slotContent = slotFactory(host);
22
- if (slotContent instanceof Element) {
23
- slotContent.setAttribute('slot', slotName);
24
- host.appendChild(slotContent);
25
- this.__slotContent = slotContent;
26
- }
27
- } else {
28
- this.__slotContent = slotted;
29
- }
30
-
31
- this.slotInitializer(host, this.__slotContent);
32
-
33
- this.__initialized = true;
34
- }
35
- }
36
- }