Skip to content
Snippets Groups Projects
Commit fe25aef8 authored by Filipa Lacerda's avatar Filipa Lacerda Committed by Felipe Artur
Browse files

Merge branch 'fix-search-not-highlighting' into 'master'

Fixed search terms not highlight

Closes #31997

See merge request !11198
parent 2e4e522a
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -584,7 +584,12 @@ GitLabDropdown = (function() {
var link = document.createElement('a');
 
link.href = url;
link.textContent = text;
if (this.highlight) {
link.innerHTML = text;
} else {
link.textContent = text;
}
 
if (selected) {
link.className = 'is-active';
Loading
Loading
---
title: Fixed search terms not correctly highlighting
merge_request:
author:
Loading
Loading
@@ -44,8 +44,8 @@ require('~/lib/utils/url_utility');
preloadFixtures('static/gl_dropdown.html.raw');
loadJSONFixtures('projects.json');
 
function initDropDown(hasRemote, isFilterable) {
this.dropdownButtonElement = $('#js-project-dropdown', this.dropdownContainerElement).glDropdown({
function initDropDown(hasRemote, isFilterable, extraOpts = {}) {
const options = Object.assign({
selectable: true,
filterable: isFilterable,
data: hasRemote ? remoteMock.bind({}, this.projectsData) : this.projectsData,
Loading
Loading
@@ -53,8 +53,9 @@ require('~/lib/utils/url_utility');
fields: ['name']
},
text: project => (project.name_with_namespace || project.name),
id: project => project.id
});
id: project => project.id,
}, extraOpts);
this.dropdownButtonElement = $('#js-project-dropdown', this.dropdownContainerElement).glDropdown(options);
}
 
beforeEach(() => {
Loading
Loading
@@ -88,6 +89,25 @@ require('~/lib/utils/url_utility');
).toBe('<script>alert("testing");</script>');
});
 
it('should output HTML when highlighting', () => {
this.projectsData[0].name_with_namespace = 'testing';
$('.dropdown-input .dropdown-input-field').val('test');
initDropDown.call(this, false, true, {
highlight: true,
});
this.dropdownButtonElement.click();
expect(
$('.dropdown-content li:first-child').text(),
).toBe('testing');
expect(
$('.dropdown-content li:first-child a').html(),
).toBe('<b>t</b><b>e</b><b>s</b><b>t</b>ing');
});
describe('that is open', () => {
beforeEach(() => {
initDropDown.call(this, false, false);
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment