Skip to content

Commit fa2fa02

Browse files
committed
use exactly the same markup for labels
1 parent 25f993b commit fa2fa02

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

templates/repo/home.tmpl

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
>
4444
<input type="hidden" name="topics" value="{{range $i, $v := .Topics}}{{.Name}}{{if lt (Add $i 1) (len $.Topics)}},{{end}}{{end}}">
4545
{{range .Topics}}
46-
{{/* lalels generated by Fomantic still use `<i class="delete icon">`, to avoid mixing different style together and to remind future developers, use it instead of svg*/}}
47-
<div class="ui small label topic transition visible" data-value="{{.Name}}" style="display: inline-block !important; cursor: default;">{{.Name}}<i class="delete icon"></i></div>
46+
{{/* lalels generated by Fomantic still use `<i class="delete icon">`, to avoid mixing different style together and to remind future developers, use it instead of svg
47+
and keep the same as template (repo-topic-label), the style is also added by Fomantic Dropdown automatically when generating new labels */}}
48+
<div class="ui small label topic transition visible" data-value="{{.Name}}" style="display: inline-block !important;">{{.Name}}<i class="delete icon"></i></div>
4849
{{end}}
4950
<div class="text"></div>
5051
</div>

web_src/js/features/repo-home.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import $ from 'jquery';
22
import {stripTags} from '../utils.js';
33
import {hideElem, showElem} from '../utils/dom.js';
4+
import {htmlEscape} from 'escape-goat';
45

56
const {appSubUrl, csrfToken} = window.config;
67

@@ -110,7 +111,7 @@ export function initRepoTopicBar() {
110111
const query = stripTags(this.urlData.query.trim());
111112
let found_query = false;
112113
const current_topics = [];
113-
topicDropdown.find('div.label.visible.topic,a.label.visible').each((_, el) => {
114+
topicDropdown.find('div.label.visible.topic').each((_, el) => {
114115
current_topics.push(el.getAttribute('data-value'));
115116
});
116117

@@ -149,9 +150,10 @@ export function initRepoTopicBar() {
149150
},
150151
onLabelCreate(value) {
151152
value = value.toLowerCase().trim();
152-
this.attr('data-value', value).contents().first().replaceWith(value);
153-
addLabelDeleteIconAria(this.find('i.delete.icon'));
154-
return this;
153+
// keep the same as template (repo-topic-label)
154+
const $el = $(`<div class="ui small label topic" data-value="${htmlEscape(value)}" >${htmlEscape(value)}<i class="delete icon"></i></div>`);
155+
addLabelDeleteIconAria($el.find('i.delete.icon'));
156+
return $el;
155157
},
156158
onAdd(addedValue, _addedText, $addedChoice) {
157159
addedValue = addedValue.toLowerCase().trim();

0 commit comments

Comments
 (0)