Skip to content

Commit 5cd082e

Browse files
committed
fix
1 parent 9d86200 commit 5cd082e

File tree

1 file changed

+27
-35
lines changed

1 file changed

+27
-35
lines changed

web_src/js/components/DiffCommitSelector.vue

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import {SvgIcon} from '../svg.ts';
33
import {GET} from '../modules/fetch.ts';
4+
import {generateAriaId} from '../modules/fomantic/base.ts';
45
56
export default {
67
components: {SvgIcon},
@@ -15,6 +16,8 @@ export default {
1516
commits: [],
1617
hoverActivated: false,
1718
lastReviewCommitSha: null,
19+
uniqueIdMenu: generateAriaId(),
20+
uniqueIdShowAll: generateAriaId(),
1821
};
1922
},
2023
computed: {
@@ -113,12 +116,10 @@ export default {
113116
}
114117
// set correct tabindex to allow easier navigation
115118
this.$nextTick(() => {
116-
const expandBtn = this.$el.querySelector('#diff-commit-list-expand');
117-
const showAllChanges = this.$el.querySelector('#diff-commit-list-show-all');
118119
if (this.menuVisible) {
119-
this.focusElem(showAllChanges, expandBtn);
120+
this.focusElem(this.$refs.showAllChanges, this.$refs.expandBtn);
120121
} else {
121-
this.focusElem(expandBtn, showAllChanges);
122+
this.focusElem(this.$refs.expandBtn, this.$refs.showAllChanges);
122123
}
123124
});
124125
},
@@ -189,23 +190,23 @@ export default {
189190
};
190191
</script>
191192
<template>
192-
<div class="ui scrolling dropdown custom">
193+
<div class="ui scrolling dropdown custom diff-commit-selector">
193194
<button
195+
ref="expandBtn"
194196
class="ui basic button"
195-
id="diff-commit-list-expand"
196197
@click.stop="toggleMenu()"
197198
:data-tooltip-content="locale.filter_changes_by_commit"
198199
aria-haspopup="true"
199-
aria-controls="diff-commit-selector-menu"
200200
:aria-label="locale.filter_changes_by_commit"
201-
aria-activedescendant="diff-commit-list-show-all"
201+
:aria-controls="uniqueIdMenu"
202+
:aria-activedescendant="uniqueIdShowAll"
202203
>
203204
<svg-icon name="octicon-git-commit"/>
204205
</button>
205206
<!-- this dropdown is not managed by Fomantic UI, so it needs some classes like "transition" explicitly -->
206-
<div class="left menu transition" id="diff-commit-selector-menu" :class="{visible: menuVisible}" v-show="menuVisible" v-cloak :aria-expanded="menuVisible ? 'true': 'false'">
207+
<div class="left menu transition" :id="uniqueIdMenu" :class="{visible: menuVisible}" v-show="menuVisible" v-cloak :aria-expanded="menuVisible ? 'true': 'false'">
207208
<div class="loading-indicator is-loading" v-if="isLoading"/>
208-
<div v-if="!isLoading" class="vertical item" id="diff-commit-list-show-all" role="menuitem" @keydown.enter="showAllChanges()" @click="showAllChanges()">
209+
<div v-if="!isLoading" class="item" :id="uniqueIdShowAll" ref="showAllChanges" role="menuitem" @keydown.enter="showAllChanges()" @click="showAllChanges()">
209210
<div class="gt-ellipsis">
210211
{{ locale.show_all_commits }}
211212
</div>
@@ -216,7 +217,7 @@ export default {
216217
<!-- only show the show changes since last review if there is a review AND we are commits ahead of the last review -->
217218
<div
218219
v-if="lastReviewCommitSha != null" role="menuitem"
219-
class="vertical item"
220+
class="item"
220221
:class="{disabled: !commitsSinceLastReview}"
221222
@keydown.enter="changesSinceLastReviewClick()"
222223
@click="changesSinceLastReviewClick()"
@@ -231,8 +232,8 @@ export default {
231232
<span v-if="!isLoading" class="info text light-2">{{ locale.select_commit_hold_shift_for_range }}</span>
232233
<template v-for="commit in commits" :key="commit.id">
233234
<div
234-
class="vertical item" role="menuitem"
235-
:class="{selection: commit.selected, hovered: commit.hovered}"
235+
class="item" role="menuitem"
236+
:class="{active: commit.selected}"
236237
@keydown.enter.exact="commitClicked(commit.id)"
237238
@keydown.enter.shift.exact="commitClickedShift(commit)"
238239
@mouseover.shift="highlight(commit)"
@@ -262,46 +263,37 @@ export default {
262263
</div>
263264
</template>
264265
<style scoped>
265-
.hovered:not(.selection) {
266-
background-color: var(--color-small-accent) !important;
267-
}
268-
.selection {
269-
background-color: var(--color-accent) !important;
270-
}
271-
272-
.info {
273-
display: inline-block;
274-
padding: 7px 14px !important;
275-
line-height: 1.4;
276-
width: 100%;
277-
}
278-
279-
#diff-commit-selector-menu {
266+
.ui.dropdown.diff-commit-selector .menu {
267+
margin-top: 0.25em;
280268
overflow-x: hidden;
281269
max-height: 450px;
282270
}
283271
284-
#diff-commit-selector-menu .loading-indicator {
272+
.ui.dropdown.diff-commit-selector .menu .loading-indicator {
285273
height: 200px;
286274
width: 350px;
287275
}
288276
289-
#diff-commit-selector-menu .item,
290-
#diff-commit-selector-menu .info {
291-
display: flex !important;
277+
.ui.dropdown.diff-commit-selector .menu > .item,
278+
.ui.dropdown.diff-commit-selector .menu > .info {
279+
display: flex;
292280
flex-direction: row;
293281
line-height: 1.4;
282+
gap: 0.25em;
294283
padding: 7px 14px !important;
284+
}
285+
286+
.ui.dropdown.diff-commit-selector .menu > .item:not(:first-child),
287+
.ui.dropdown.diff-commit-selector .menu > .info:not(:first-child) {
295288
border-top: 1px solid var(--color-secondary) !important;
296-
gap: 0.25em;
297289
}
298290
299-
#diff-commit-selector-menu .item:focus {
291+
.ui.dropdown.diff-commit-selector .menu > .item:focus {
300292
color: var(--color-text);
301293
background: var(--color-hover);
302294
}
303295
304-
#diff-commit-selector-menu .commit-list-summary {
296+
.ui.dropdown.diff-commit-selector .menu .commit-list-summary {
305297
max-width: min(380px, 96vw);
306298
}
307299
</style>

0 commit comments

Comments
 (0)