nsw-design-system 3.11.0 → 3.11.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/dist/js/main.js CHANGED
@@ -1333,7 +1333,7 @@
1333
1333
  this.updateTriggerAria(ariaLabel);
1334
1334
  }
1335
1335
  initButtonSelect() {
1336
- const triggerLabel = this.getSelectedOptionText(this.element);
1336
+ const triggerLabel = this.getSelectedOptionText();
1337
1337
  const button = `<button class="nsw-button nsw-multi-select__button" aria-label="${triggerLabel[1]}" aria-expanded="false" aria-controls="${this.selectId}-dropdown">
1338
1338
  <span aria-hidden="true" class="nsw-multi-select__label">${triggerLabel[0]}</span>
1339
1339
  <span class="material-icons nsw-material-icons" focusable="false" aria-hidden="true">keyboard_arrow_down</span>
@@ -1358,15 +1358,16 @@
1358
1358
  let label = '';
1359
1359
  let ariaLabel = '';
1360
1360
  const count = this.getSelectedOptionCount();
1361
- if (count === this.options.length) {
1361
+ if (count === this.options.length && this.dropdown) {
1362
1362
  label = `All ${this.textSelected}`;
1363
1363
  ariaLabel = `All ${this.textSelected}`;
1364
1364
  } else if (count > 1) {
1365
1365
  label = `${count} ${this.textSelected}`;
1366
1366
  ariaLabel = `${count} ${this.textSelected}, Please select`;
1367
- } else if (count > 0) {
1368
- ariaLabel += `${this.options[0].text}, Please select`;
1369
- label = this.options[0].text;
1367
+ } else if (count === 1) {
1368
+ const selectedOption = this.getSelectedOption();
1369
+ label = selectedOption.closest('.nsw-multi-select__option').getAttribute('data-label');
1370
+ ariaLabel = `${label}, Please select`;
1370
1371
  } else {
1371
1372
  label = noSelectionText;
1372
1373
  ariaLabel = 'Please select';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsw-design-system",
3
- "version": "3.11.0",
3
+ "version": "3.11.2",
4
4
  "description": "Design system for Digital NSW",
5
5
  "main": "dist/main.js",
6
6
  "style": "dist/main.css",
@@ -215,7 +215,7 @@ class Select {
215
215
  }
216
216
 
217
217
  initButtonSelect() {
218
- const triggerLabel = this.getSelectedOptionText(this.element)
218
+ const triggerLabel = this.getSelectedOptionText()
219
219
 
220
220
  const button = `<button class="nsw-button nsw-multi-select__button" aria-label="${triggerLabel[1]}" aria-expanded="false" aria-controls="${this.selectId}-dropdown">
221
221
  <span aria-hidden="true" class="nsw-multi-select__label">${triggerLabel[0]}</span>
@@ -246,15 +246,16 @@ class Select {
246
246
  let ariaLabel = ''
247
247
  const count = this.getSelectedOptionCount()
248
248
 
249
- if (count === this.options.length) {
249
+ if (count === this.options.length && this.dropdown) {
250
250
  label = `All ${this.textSelected}`
251
251
  ariaLabel = `All ${this.textSelected}`
252
252
  } else if (count > 1) {
253
253
  label = `${count} ${this.textSelected}`
254
254
  ariaLabel = `${count} ${this.textSelected}, Please select`
255
- } else if (count > 0) {
256
- ariaLabel += `${this.options[0].text}, Please select`
257
- label = this.options[0].text
255
+ } else if (count === 1) {
256
+ const selectedOption = this.getSelectedOption()
257
+ label = selectedOption.closest('.nsw-multi-select__option').getAttribute('data-label')
258
+ ariaLabel = `${label}, Please select`
258
259
  } else {
259
260
  label = noSelectionText
260
261
  ariaLabel = 'Please select'