BigW Consortium Gitlab

Commit ed49a8e3 by Alfredo Sumaran

Merge branch 'fix-edit-last-visual-token' into 'master'

Fix edit last visual token See merge request !9791
parents b87d5c88 dfd0e100
...@@ -178,9 +178,9 @@ class FilteredSearchVisualTokens { ...@@ -178,9 +178,9 @@ class FilteredSearchVisualTokens {
const inputLi = input.parentElement; const inputLi = input.parentElement;
const tokenContainer = document.querySelector('.tokens-container'); const tokenContainer = document.querySelector('.tokens-container');
if (!tokenContainer.lastElementChild.isEqualNode(inputLi)) { FilteredSearchVisualTokens.tokenizeInput();
FilteredSearchVisualTokens.tokenizeInput();
if (!tokenContainer.lastElementChild.isEqualNode(inputLi)) {
const { isLastVisualTokenValid } = const { isLastVisualTokenValid } =
gl.FilteredSearchVisualTokens.getLastVisualTokenBeforeInput(); gl.FilteredSearchVisualTokens.getLastVisualTokenBeforeInput();
......
...@@ -533,12 +533,12 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -533,12 +533,12 @@ describe('Filtered Search Visual Tokens', () => {
FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', 'none'), FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', 'none'),
); );
spyOn(gl.FilteredSearchVisualTokens, 'tokenizeInput').and.callThrough(); spyOn(gl.FilteredSearchVisualTokens, 'tokenizeInput').and.callFake(() => {});
spyOn(gl.FilteredSearchVisualTokens, 'getLastVisualTokenBeforeInput').and.callThrough(); spyOn(gl.FilteredSearchVisualTokens, 'getLastVisualTokenBeforeInput').and.callThrough();
gl.FilteredSearchVisualTokens.moveInputToTheRight(); gl.FilteredSearchVisualTokens.moveInputToTheRight();
expect(gl.FilteredSearchVisualTokens.tokenizeInput).not.toHaveBeenCalled(); expect(gl.FilteredSearchVisualTokens.tokenizeInput).toHaveBeenCalled();
expect(gl.FilteredSearchVisualTokens.getLastVisualTokenBeforeInput).not.toHaveBeenCalled(); expect(gl.FilteredSearchVisualTokens.getLastVisualTokenBeforeInput).not.toHaveBeenCalled();
}); });
...@@ -583,5 +583,18 @@ describe('Filtered Search Visual Tokens', () => { ...@@ -583,5 +583,18 @@ describe('Filtered Search Visual Tokens', () => {
expect(tokensContainer.children[2].querySelector('.filtered-search')).not.toEqual(null); expect(tokensContainer.children[2].querySelector('.filtered-search')).not.toEqual(null);
}); });
it('tokenizes input even if input is the right most element', () => {
tokensContainer.innerHTML = `
${FilteredSearchSpecHelper.createFilterVisualTokenHTML('label', 'none')}
${FilteredSearchSpecHelper.createNameFilterVisualTokenHTML('label')}
${FilteredSearchSpecHelper.createInputHTML('', '~bug')}
`;
gl.FilteredSearchVisualTokens.moveInputToTheRight();
const token = tokensContainer.children[1];
expect(token.querySelector('.value').innerText).toEqual('~bug');
});
}); });
}); });
...@@ -33,10 +33,10 @@ class FilteredSearchSpecHelper { ...@@ -33,10 +33,10 @@ class FilteredSearchSpecHelper {
`; `;
} }
static createInputHTML(placeholder = '') { static createInputHTML(placeholder = '', value = '') {
return ` return `
<li class="input-token"> <li class="input-token">
<input type='text' class='filtered-search' placeholder='${placeholder}' /> <input type='text' class='filtered-search' placeholder='${placeholder}' value='${value}'/>
</li> </li>
`; `;
} }
......
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