@projectcaluma/ember-form 14.4.2 → 14.4.4

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.
@@ -14,7 +14,7 @@
14
14
  <UkIcon @icon="warning" class="uk-margin-small-right" />
15
15
  {{t "caluma.form.validation.error"}}
16
16
  </div>
17
- <ul class="uk-list uk-list-bullet">
17
+ <ul class="uk-list uk-list-disc">
18
18
  {{#each this.invalidFields as |invalidField|}}
19
19
  <li>
20
20
  <LinkTo
@@ -26,5 +26,7 @@
26
26
  @onClose={{this.onClose}}
27
27
  @minDate={{@minDate}}
28
28
  @maxDate={{@maxDate}}
29
+ aria-labelledby={{@field.labelId}}
30
+ ...attributes
29
31
  />
30
32
  </div>
@@ -34,6 +34,28 @@ export default class CfFieldInputDateComponent extends Component {
34
34
  @action
35
35
  onReady(_selectedDates, _dateStr, flatpickrRef) {
36
36
  this.flatpickrRef = flatpickrRef;
37
+
38
+ // Flatpickr generates an alternative input field (altInput) that does not
39
+ // copy over all attributes from the original input field. This fails in
40
+ // accessibility checks when using aria attributes to account for a11y
41
+ // compatibility.
42
+ //
43
+ // There's an issue (https://github.com/flatpickr/flatpickr/issues/1906)
44
+ // about that and also an open PR
45
+ // (https://github.com/flatpickr/flatpickr/pull/2821) to fix it. However,
46
+ // flatpickr has not seen a new commit since 2022 and seems to be
47
+ // deprecated.
48
+ //
49
+ // In order to not have to search for a new datepicker solution, we fix the
50
+ // a11y issue ourselves by copying over all aria-* attributes to the alt
51
+ // input.
52
+ const { input, altInput } = flatpickrRef;
53
+
54
+ input
55
+ .getAttributeNames()
56
+ .filter((attr) => attr.startsWith("aria-"))
57
+ .filter((attr) => !altInput.hasAttribute(attr))
58
+ .forEach((attr) => altInput.setAttribute(attr, input.getAttribute(attr)));
37
59
  }
38
60
 
39
61
  @action
@@ -14,6 +14,7 @@
14
14
  @searchPlaceholder={{t "caluma.form.power-select.search-placeholder"}}
15
15
  @noMatchesMessage={{t "caluma.form.power-select.search-empty"}}
16
16
  @onChange={{this.change}}
17
+ aria-labelledby={{@field.labelId}}
17
18
  as |option|
18
19
  >
19
20
  {{#if (and option.disabled (not @disabled))}}
@@ -1,4 +1,9 @@
1
- <label class="uk-form-label" for={{@field.pk}} ...attributes>
1
+ <label
2
+ class="uk-form-label"
3
+ for={{@field.pk}}
4
+ id={{@field.labelId}}
5
+ ...attributes
6
+ >
2
7
  <span class="uk-text-bold">
3
8
  {{@field.question.raw.label}}
4
9
  </span>
@@ -105,6 +105,12 @@ export default class CfFieldComponent extends Component {
105
105
 
106
106
  yield this.args.field.validate.perform();
107
107
 
108
+ if (this.args.field.isInvalid) {
109
+ // If the frontend validation fails, we don't need to try saving the value
110
+ // to the backend as the backend will throw an error as well.
111
+ return;
112
+ }
113
+
108
114
  return yield this.args.field.save.unlinked().perform();
109
115
  }
110
116
 
@@ -177,6 +177,15 @@ export default class Field extends Base {
177
177
  return `${this.document.pk}:Question:${this.raw.question.slug}`;
178
178
  }
179
179
 
180
+ /**
181
+ * The element ID used by the label component.
182
+ *
183
+ * @property {String} labelId
184
+ */
185
+ get labelId() {
186
+ return `${this.pk}:label`;
187
+ }
188
+
180
189
  /**
181
190
  * Whether the field is valid.
182
191
  *
@@ -627,6 +636,12 @@ export default class Field extends Base {
627
636
  this.answer.pushIntoStore();
628
637
  }
629
638
 
639
+ if (this._errors.filter(({ type }) => type === "format").length) {
640
+ // If we previously had a format validator error but now the request
641
+ // succeeded, we need to remove said error again.
642
+ this._errors = this._errors.filter(({ type }) => type !== "format");
643
+ }
644
+
630
645
  return response;
631
646
  } catch (e) {
632
647
  const validationError = e.errors.find(
@@ -643,7 +658,6 @@ export default class Field extends Base {
643
658
  },
644
659
  ];
645
660
  } else {
646
- this._errors = [];
647
661
  throw e;
648
662
  }
649
663
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form",
3
- "version": "14.4.2",
3
+ "version": "14.4.4",
4
4
  "description": "Ember addon for rendering Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -41,7 +41,7 @@
41
41
  "luxon": "^3.5.0",
42
42
  "reactiveweb": "^1.3.0",
43
43
  "tracked-toolbox": "^2.0.0",
44
- "@projectcaluma/ember-core": "^14.4.2"
44
+ "@projectcaluma/ember-core": "^14.4.4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@ember/optional-features": "2.2.0",
@@ -59,7 +59,7 @@
59
59
  "ember-cli-sri": "2.1.1",
60
60
  "ember-cli-terser": "4.0.2",
61
61
  "ember-load-initializers": "3.0.1",
62
- "ember-qunit": "9.0.3",
62
+ "ember-qunit": "9.0.4",
63
63
  "ember-resolver": "13.1.1",
64
64
  "ember-source": "6.1.0",
65
65
  "ember-source-channel-url": "3.0.0",
@@ -68,16 +68,16 @@
68
68
  "miragejs": "0.1.48",
69
69
  "qunit": "2.24.1",
70
70
  "qunit-dom": "3.5.0",
71
- "sass": "1.92.1",
72
- "uikit": "3.23.12",
71
+ "sass": "1.93.2",
72
+ "uikit": "3.23.13",
73
73
  "uuid": "13.0.0",
74
74
  "webpack": "5.101.3",
75
- "@projectcaluma/ember-testing": "14.4.2",
76
- "@projectcaluma/ember-workflow": "14.4.2"
75
+ "@projectcaluma/ember-workflow": "14.4.4",
76
+ "@projectcaluma/ember-testing": "14.4.4"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "ember-source": ">= 4.0.0",
80
- "@projectcaluma/ember-workflow": "^14.4.2"
80
+ "@projectcaluma/ember-workflow": "^14.4.4"
81
81
  },
82
82
  "dependenciesMeta": {
83
83
  "@projectcaluma/ember-core": {