From 2fc7a1f600c0caa5c681b8abdb6f772bbac1b927 Mon Sep 17 00:00:00 2001 From: Precious Onyenaucheya Date: Tue, 19 Sep 2023 22:33:41 +0100 Subject: [PATCH] revert changes --- src/components/autosuggest/autosuggest.spec.js | 9 ++++++--- src/components/autosuggest/autosuggest.ui.js | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/autosuggest/autosuggest.spec.js b/src/components/autosuggest/autosuggest.spec.js index f585ee74e0..409e21e169 100644 --- a/src/components/autosuggest/autosuggest.spec.js +++ b/src/components/autosuggest/autosuggest.spec.js @@ -603,9 +603,12 @@ describe('script: autosuggest', () => { expect(warningText.trim()).toBe('!Sorry, there is a problem.'); }); - it('the results list and title elements should be removed from the page', async () => { - expect($('.ons-js-autosuggest-listbox').length).toBe(0); - expect($('.ons-autosuggest__results-title').length).toBe(0); + it('the list and results element should be removed from the page', async () => { + const hasListBox = await page.$eval('.ons-autosuggest', (node) => node.classList.contains('.ons-js-autosuggest-listbox')); + const hasResultsTitle = await page.$eval('.ons-autosuggest', (node) => node.classList.contains('.ons-autosuggest__results-title')); + + expect(hasListBox).toBe(false); + expect(hasResultsTitle).toBe(false); }); it('the input should be disabled', async () => { diff --git a/src/components/autosuggest/autosuggest.ui.js b/src/components/autosuggest/autosuggest.ui.js index c8bfb8310c..95f1943a82 100644 --- a/src/components/autosuggest/autosuggest.ui.js +++ b/src/components/autosuggest/autosuggest.ui.js @@ -43,7 +43,7 @@ export default class AutosuggestUI { this.input = context.querySelector(`.${baseClass}-input`); this.resultsContainer = context.querySelector(`.${baseClass}-results`); this.listbox = this.resultsContainer.querySelector(`.${baseClass}-listbox`); - this.resultsTitleContainer = this.resultsContainer.querySelector(`.${baseClass}__results-title`); + this.resultsTitleContainer = this.resultsContainer.querySelector(`.ons-autosuggest__results-title`); this.instructions = context.querySelector(`.${baseClass}-instructions`); this.ariaStatus = context.querySelector(`.${baseClass}-aria-status`); this.form = context.closest('form'); @@ -418,7 +418,6 @@ export default class AutosuggestUI { this.input.value = ''; this.label.classList.add('ons-u-lighter'); - this.listbox.innerHTML = ''; this.resultsContainer.insertBefore(this.createWarningElement(message), this.resultsContainer.firstChild); this.ariaStatus.setAttribute('aria-hidden', 'true'); this.setAriaStatus(ariaMessage);