Commit a5a339b7 authored by mbergeron's avatar mbergeron

Prevent an issue where dropdown links would not be clickable

This commit fixes a Bootstrap dropdown re-initialization when the
SearchAutocomplete component is in use.

There was an issue with the way the autocomplete component would
trigger an event to the dropdown which caused a re-initialization.
parent dfb38bf8
......@@ -407,7 +407,7 @@ export class SearchAutocomplete {
disableAutocomplete() {
if (!this.searchInput.hasClass('js-autocomplete-disabled') && this.dropdown.hasClass('show')) {
this.searchInput.addClass('js-autocomplete-disabled');
this.dropdown.dropdown('toggle');
this.dropdownToggle.dropdown('toggle');
this.restoreMenu();
}
}
......
---
title: Fix an issue where the Search dropdown results would not be clickable.
merge_request: 30087
author: mbergeron
type: fixed
......@@ -188,4 +188,28 @@ describe('Search autocomplete dropdown', () => {
// example) on JavaScript-created keypresses.
expect(submitSpy).not.toHaveBeenTriggered();
});
describe('disableAutocomplete', function() {
beforeEach(function() {
widget.enableAutocomplete();
});
it('should close the Dropdown', function() {
const toggleSpy = spyOn(widget.dropdownToggle, 'dropdown');
widget.dropdown.addClass('show');
widget.disableAutocomplete();
expect(toggleSpy).toHaveBeenCalledWith('toggle');
});
});
describe('enableAutocomplete', function() {
it('should open the Dropdown', function() {
const toggleSpy = spyOn(widget.dropdownToggle, 'dropdown');
widget.enableAutocomplete();
expect(toggleSpy).toHaveBeenCalledWith('toggle');
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment