Skip to content

Commit 8a4382b

Browse files
committed
improve
1 parent 9aaf699 commit 8a4382b

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

templates/repo/issue/view_content/sidebar.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<input type="text" placeholder="{{.locale.Tr "repo.issues.filter_labels"}}">
122122
</div>
123123
{{end}}
124-
<div class="no-select item">{{.locale.Tr "repo.issues.new.clear_labels"}}</div>
124+
<a class="no-select item" href="#">{{.locale.Tr "repo.issues.new.clear_labels"}}</a>
125125
{{if or .Labels .OrgLabels}}
126126
{{$previousExclusiveScope := "_no_scope"}}
127127
{{range .Labels}}

web_src/js/features/aria.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ function attachOneDropdownAria($dropdown) {
8181
$dropdown.on('keydown', (e) => {
8282
// here it must use keydown event before dropdown's keyup handler, otherwise there is no Enter event in our keyup handler
8383
if (e.key === 'Enter') {
84-
const $item = $dropdown.dropdown('get item', $dropdown.dropdown('get value'));
84+
let $item = $dropdown.dropdown('get item', $dropdown.dropdown('get value'));
85+
if (!$item) $item = $menu.find('> .item.selected'); // when dropdown filters items by input, there is no "value", so query the "selected" item
8586
// if the selected item is clickable, then trigger the click event. in the future there could be a special CSS class for it.
8687
if ($item && $item.is('a')) $item[0].click();
8788
}

web_src/js/features/repo-legacy.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ export function initRepoCommentForm() {
8686
let hasUpdateAction = $listMenu.data('action') === 'update';
8787
const items = {};
8888

89-
$(`.${selector}`).dropdown('setting', 'onHide', () => {
90-
hasUpdateAction = $listMenu.data('action') === 'update'; // Update the var
91-
if (hasUpdateAction) {
92-
// TODO: Add batch functionality and make this 1 network request.
93-
(async function() {
89+
$(`.${selector}`).dropdown({
90+
'action': 'nothing', // do not hide the menu if user presses Enter
91+
async onHide() {
92+
hasUpdateAction = $listMenu.data('action') === 'update'; // Update the var
93+
if (hasUpdateAction) {
94+
// TODO: Add batch functionality and make this 1 network request.
9495
for (const [elementId, item] of Object.entries(items)) {
9596
await updateIssuesMeta(
9697
item['update-url'],
@@ -100,8 +101,8 @@ export function initRepoCommentForm() {
100101
);
101102
}
102103
window.location.reload();
103-
})();
104-
}
104+
}
105+
},
105106
});
106107

107108
$listMenu.find('.item:not(.no-select)').on('click', function (e) {

0 commit comments

Comments
 (0)