@ons/design-system 65.2.3 → 65.2.5

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.
@@ -597,12 +597,20 @@ describe('script: autosuggest', () => {
597
597
  });
598
598
 
599
599
  it('shows the API error message', async () => {
600
- const listItemCount = await page.$$eval('.ons-js-autosuggest-listbox > *', (nodes) => nodes.length);
601
- expect(listItemCount).toBe(1);
600
+ const resultsItemCount = await page.$$eval('.ons-js-autosuggest-results > *', (nodes) => nodes.length);
601
+ expect(resultsItemCount).toBe(1);
602
602
  const warningText = await page.$eval('.ons-autosuggest__warning', (node) => node.textContent);
603
603
  expect(warningText.trim()).toBe('!Sorry, there is a problem.');
604
604
  });
605
605
 
606
+ it('the list and results element should be removed from the page', async () => {
607
+ const hasListBox = await page.$eval('.ons-autosuggest', (node) => node.classList.contains('.ons-js-autosuggest-listbox'));
608
+ const hasResultsTitle = await page.$eval('.ons-autosuggest', (node) => node.classList.contains('.ons-autosuggest__results-title'));
609
+
610
+ expect(hasListBox).toBe(false);
611
+ expect(hasResultsTitle).toBe(false);
612
+ });
613
+
606
614
  it('the input should be disabled', async () => {
607
615
  const hasDisabledAttribute = await page.$eval('.ons-js-autosuggest-input', (node) => node.hasAttribute('disabled'));
608
616
  expect(hasDisabledAttribute).toBe(true);
@@ -43,6 +43,7 @@ export default class AutosuggestUI {
43
43
  this.input = context.querySelector(`.${baseClass}-input`);
44
44
  this.resultsContainer = context.querySelector(`.${baseClass}-results`);
45
45
  this.listbox = this.resultsContainer.querySelector(`.${baseClass}-listbox`);
46
+ this.resultsTitleContainer = this.resultsContainer.querySelector(`.ons-autosuggest__results-title`);
46
47
  this.instructions = context.querySelector(`.${baseClass}-instructions`);
47
48
  this.ariaStatus = context.querySelector(`.${baseClass}-aria-status`);
48
49
  this.form = context.closest('form');
@@ -376,7 +377,10 @@ export default class AutosuggestUI {
376
377
 
377
378
  if (this.resultLimit === 100 && this.foundResults > this.resultLimit) {
378
379
  let message = this.tooManyResults.replace('{n}', this.foundResults);
379
- this.listbox.insertBefore(this.createWarningElement(message), this.listbox.firstChild);
380
+ this.resultsContainer.insertBefore(this.createWarningElement(message), this.resultsContainer.firstChild);
381
+ this.ariaStatus.setAttribute('aria-hidden', 'true');
382
+ this.listbox.remove();
383
+ this.resultsTitleContainer.remove();
380
384
  }
381
385
 
382
386
  this.setHighlightedResult(null);
@@ -414,9 +418,11 @@ export default class AutosuggestUI {
414
418
  this.input.value = '';
415
419
  this.label.classList.add('ons-u-lighter');
416
420
 
417
- this.listbox.innerHTML = '';
418
- this.listbox.insertBefore(this.createWarningElement(message), this.listbox.firstChild);
421
+ this.resultsContainer.insertBefore(this.createWarningElement(message), this.resultsContainer.firstChild);
422
+ this.ariaStatus.setAttribute('aria-hidden', 'true');
419
423
  this.setAriaStatus(ariaMessage);
424
+ this.listbox.remove();
425
+ this.resultsTitleContainer.remove();
420
426
  } else {
421
427
  message = this.noResults;
422
428
  this.listbox.innerHTML = `<li class="${classAutosuggestOption} ${classAutosuggestOptionNoResults}">${message}</li>`;
@@ -497,13 +503,12 @@ export default class AutosuggestUI {
497
503
  }
498
504
 
499
505
  createWarningElement(content) {
500
- const warningListElement = document.createElement('li');
506
+ const warningContainer = document.createElement('div');
501
507
  const warningElement = document.createElement('div');
502
508
  const warningSpanElement = document.createElement('span');
503
509
  const warningBodyElement = document.createElement('div');
504
510
 
505
- warningListElement.setAttribute('aria-hidden', 'true');
506
- warningListElement.className = 'ons-autosuggest__warning';
511
+ warningContainer.className = 'ons-autosuggest__warning';
507
512
  warningElement.className = 'ons-panel ons-panel--warn ons-autosuggest__panel';
508
513
 
509
514
  warningSpanElement.className = 'ons-panel__icon';
@@ -515,9 +520,9 @@ export default class AutosuggestUI {
515
520
 
516
521
  warningElement.appendChild(warningSpanElement);
517
522
  warningElement.appendChild(warningBodyElement);
518
- warningListElement.appendChild(warningElement);
523
+ warningContainer.appendChild(warningElement);
519
524
 
520
- return warningListElement;
525
+ return warningContainer;
521
526
  }
522
527
 
523
528
  storeExistingSelections(value) {
@@ -94,7 +94,6 @@ $checkbox-padding: 11px;
94
94
 
95
95
  &:checked,
96
96
  &:focus {
97
- background-color: initial;
98
97
 
99
98
  & + .ons-checkbox__label::before {
100
99
  background: none;
@@ -123,7 +122,6 @@ $checkbox-padding: 11px;
123
122
 
124
123
  &:checked,
125
124
  &:focus {
126
- background-color: initial;
127
125
 
128
126
  & + .ons-checkbox__label::before {
129
127
  background: none;
@@ -1,5 +1,3 @@
1
- import { GetViewportDetails } from 'viewport-details';
2
-
3
1
  import onViewportChange from '../../js/utils/viewport-change';
4
2
 
5
3
  const attrExpanded = 'aria-expanded';
@@ -24,6 +24,6 @@
24
24
  {% if tab.showTitle %}<h2 id="{{ tab.title|trim|replace(' ','-')|lower + '-content-title' }}" class="ons-u-vh">{{ tab.title }}</h2>{% endif %}
25
25
  {{ tab.content | safe }}
26
26
  </section>
27
- {% endfor %}
27
+ {% endfor %}
28
28
  </section>
29
29
  {% endmacro %}
@@ -76,11 +76,7 @@ describe('macro: tabs', () => {
76
76
  it('has the provided `title`', () => {
77
77
  const $ = cheerio.load(renderComponent('tabs', EXAMPLE_TABS));
78
78
 
79
- expect(
80
- $('.ons-tabs__title')
81
- .text()
82
- .trim(),
83
- ).toBe('Example tabs');
79
+ expect($('.ons-tabs__title').text().trim()).toBe('Example tabs');
84
80
  });
85
81
 
86
82
  it('has title with provided tag override', () => {
@@ -113,11 +109,7 @@ describe('macro: tabs', () => {
113
109
  const $ = cheerio.load(renderComponent('tabs', EXAMPLE_TABS));
114
110
 
115
111
  expect($('.ons-tab:first').html()).toBe('Tab 1<span class="ons-u-vh">for Example</span>');
116
- expect(
117
- $('.ons-tab:last')
118
- .text()
119
- .trim(),
120
- ).toBe('Tab 2');
112
+ expect($('.ons-tab:last').text().trim()).toBe('Tab 2');
121
113
  });
122
114
 
123
115
  it('has Google Analytics integration on tab links', () => {
@@ -133,16 +125,8 @@ describe('macro: tabs', () => {
133
125
  it('has expected content in tab panels', () => {
134
126
  const $ = cheerio.load(renderComponent('tabs', EXAMPLE_TABS));
135
127
 
136
- expect(
137
- $('.ons-tabs__panel:first')
138
- .html()
139
- .trim(),
140
- ).toBe('Example content...');
141
- expect(
142
- $('.ons-tabs__panel:last')
143
- .html()
144
- .trim(),
145
- ).toBe('Some nested <strong>strong element</strong>...');
128
+ expect($('.ons-tabs__panel:first').html().trim()).toBe('Example content...');
129
+ expect($('.ons-tabs__panel:last').html().trim()).toBe('Some nested <strong>strong element</strong>...');
146
130
  });
147
131
 
148
132
  it('displays a h2 when showTitle set to true', () => {