Commit 640e977d authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch '27966-branch-ref-switcher-input-filter-broken' into 'master'

Display loading indicator when filtering ref switcher dropdown

Closes #27966

See merge request !9144
parents 01dfedbc 010c9337
...@@ -47,9 +47,11 @@ ...@@ -47,9 +47,11 @@
} }
// Only filter asynchronously only if option remote is set // Only filter asynchronously only if option remote is set
if (this.options.remote) { if (this.options.remote) {
$inputContainer.parent().addClass('is-loading');
clearTimeout(timeout); clearTimeout(timeout);
return timeout = setTimeout(function() { return timeout = setTimeout(function() {
return this.options.query(this.input.val(), function(data) { return this.options.query(this.input.val(), function(data) {
$inputContainer.parent().removeClass('is-loading');
return this.options.callback(data); return this.options.callback(data);
}.bind(this)); }.bind(this));
}.bind(this), 250); }.bind(this), 250);
......
---
title: Display loading indicator when filtering ref switcher dropdown
merge_request:
author:
...@@ -20,10 +20,10 @@ feature 'Ref switcher', feature: true, js: true do ...@@ -20,10 +20,10 @@ feature 'Ref switcher', feature: true, js: true do
input.set 'binary' input.set 'binary'
wait_for_ajax wait_for_ajax
input.native.send_keys :down page.within '.dropdown-content ul' do
input.native.send_keys :down
input.native.send_keys :enter input.native.send_keys :enter
end end
end
expect(page).to have_title 'binary-encoding' expect(page).to have_title 'binary-encoding'
end end
......
...@@ -139,6 +139,14 @@ require('~/lib/utils/url_utility'); ...@@ -139,6 +139,14 @@ require('~/lib/utils/url_utility');
this.dropdownButtonElement.click(); this.dropdownButtonElement.click();
}); });
it('should show loading indicator while search results are being fetched by backend', () => {
const dropdownMenu = document.querySelector('.dropdown-menu');
expect(dropdownMenu.className.indexOf('is-loading') !== -1).toEqual(true);
remoteCallback();
expect(dropdownMenu.className.indexOf('is-loading') !== -1).toEqual(false);
});
it('should not focus search input while remote task is not complete', () => { it('should not focus search input while remote task is not complete', () => {
expect($(document.activeElement)).not.toEqual($(SEARCH_INPUT_SELECTOR)); expect($(document.activeElement)).not.toEqual($(SEARCH_INPUT_SELECTOR));
remoteCallback(); remoteCallback();
......
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