Skip to content

Commit 91edc9c

Browse files
committed
fix(user_status): Use native radio buttons for online status selection
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 5f205fe commit 91edc9c

File tree

1 file changed

+61
-41
lines changed

1 file changed

+61
-41
lines changed

apps/user_status/src/components/PredefinedStatus.vue

+61-41
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@
1919
-
2020
-->
2121
<template>
22-
<li class="predefined-status"
23-
tabindex="0"
24-
role="radio"
25-
:aria-checked="`${selected}`"
26-
@keyup.enter="select"
27-
@keyup.space="select"
28-
@click="select">
29-
<span aria-hidden="true" class="predefined-status__icon">
30-
{{ icon }}
31-
</span>
32-
<span class="predefined-status__message">
33-
{{ message }}
34-
</span>
35-
<span class="predefined-status__clear-at">
36-
{{ clearAt | clearAtFilter }}
37-
</span>
22+
<li class="predefined-status">
23+
<input :id="id"
24+
class="predefined-status__input"
25+
type="radio"
26+
name="predefined-status"
27+
:checked="selected"
28+
@change="select">
29+
<label class="predefined-status__label" :for="id">
30+
<span aria-hidden="true" class="predefined-status__label--icon">
31+
{{ icon }}
32+
</span>
33+
<span class="predefined-status__label--message">
34+
{{ message }}
35+
</span>
36+
<span class="predefined-status__label--clear-at">
37+
{{ clearAt | clearAtFilter }}
38+
</span>
39+
</label>
3840
</li>
3941
</template>
4042

@@ -70,6 +72,11 @@ export default {
7072
default: false,
7173
},
7274
},
75+
computed: {
76+
id() {
77+
return `user-status-predefined-status-${this.messageId}`
78+
},
79+
},
7380
methods: {
7481
/**
7582
* Emits an event when the user clicks the row
@@ -83,39 +90,52 @@ export default {
8390

8491
<style lang="scss" scoped>
8592
.predefined-status {
86-
display: flex;
87-
flex-wrap: nowrap;
88-
justify-content: flex-start;
89-
flex-basis: 100%;
90-
border-radius: var(--border-radius);
91-
align-items: center;
92-
min-height: 44px;
93+
&__label {
94+
display: flex;
95+
flex-wrap: nowrap;
96+
justify-content: flex-start;
97+
flex-basis: 100%;
98+
border-radius: var(--border-radius);
99+
align-items: center;
100+
min-height: 44px;
93101

94-
&:hover,
95-
&:focus {
96-
background-color: var(--color-background-hover);
97-
}
102+
&--icon {
103+
flex-basis: 40px;
104+
text-align: center;
105+
}
98106

99-
&:active{
100-
background-color: var(--color-background-dark);
101-
}
107+
&--message {
108+
font-weight: bold;
109+
padding: 0 6px;
110+
}
111+
112+
&--clear-at {
113+
color: var(--color-text-maxcontrast);
102114

103-
&__icon {
104-
flex-basis: 40px;
105-
text-align: center;
115+
&::before {
116+
content: ' – ';
117+
}
118+
}
106119
}
107120

108-
&__message {
109-
font-weight: bold;
110-
padding: 0 6px;
121+
&__input:checked + &__label,
122+
&__input:focus + &__label,
123+
&__label:hover {
124+
background-color: var(--color-background-hover);
111125
}
112126

113-
&__clear-at {
114-
color: var(--color-text-maxcontrast);
127+
&__label:active {
128+
background-color: var(--color-background-dark);
129+
}
115130

116-
&::before {
117-
content: ' – ';
118-
}
131+
// Inputs are here for keyboard navigation, they are not visually visible
132+
&__input {
133+
position: absolute;
134+
top: auto;
135+
left: -10000px;
136+
overflow: hidden;
137+
width: 1px;
138+
height: 1px;
119139
}
120140
}
121141
</style>

0 commit comments

Comments
 (0)