Fix autocomplete initial undefined state
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/26775
This commit is contained in:
parent
b60de9c0fd
commit
cfe83509c0
3 changed files with 38 additions and 3 deletions
|
@ -367,9 +367,14 @@
|
||||||
return $input.trigger('keyup');
|
return $input.trigger('keyup');
|
||||||
},
|
},
|
||||||
isLoading(data) {
|
isLoading(data) {
|
||||||
if (!data || !data.length) return false;
|
var dataToInspect = data;
|
||||||
if (Array.isArray(data)) data = data[0];
|
if (data && data.length > 0) {
|
||||||
return data === this.defaultLoadingData[0] || data.name === this.defaultLoadingData[0];
|
dataToInspect = data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
var loadingState = this.defaultLoadingData[0];
|
||||||
|
return dataToInspect &&
|
||||||
|
(dataToInspect === loadingState || dataToInspect.name === loadingState);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue