BigW Consortium Gitlab

Commit c4a9ea6c by Fatih Acet Committed by Robert Speicher

Merge branch '26775-fix-auto-complete-initial-loading' into 'master'

Fix autocomplete initial undefined state (loading) Closes #26775 See merge request !8667
parent b0aec417
......@@ -367,9 +367,14 @@
return $input.trigger('keyup');
},
isLoading(data) {
if (!data || !data.length) return false;
if (Array.isArray(data)) data = data[0];
return data === this.defaultLoadingData[0] || data.name === this.defaultLoadingData[0];
var dataToInspect = data;
if (data && data.length > 0) {
dataToInspect = data[0];
}
var loadingState = this.defaultLoadingData[0];
return dataToInspect &&
(dataToInspect === loadingState || dataToInspect.name === loadingState);
}
};
......
---
title: Fix autocomplete initial undefined state
merge_request:
author:
......@@ -62,4 +62,30 @@ describe('GfmAutoComplete', function () {
});
});
});
describe('isLoading', function () {
it('should be true with loading data object item', function () {
expect(GfmAutoComplete.isLoading({ name: 'loading' })).toBe(true);
});
it('should be true with loading data array', function () {
expect(GfmAutoComplete.isLoading(['loading'])).toBe(true);
});
it('should be true with loading data object array', function () {
expect(GfmAutoComplete.isLoading([{ name: 'loading' }])).toBe(true);
});
it('should be false with actual array data', function () {
expect(GfmAutoComplete.isLoading([
{ title: 'Foo' },
{ title: 'Bar' },
{ title: 'Qux' },
])).toBe(false);
});
it('should be false with actual data item', function () {
expect(GfmAutoComplete.isLoading({ title: 'Foo' })).toBe(false);
});
});
});
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