Skip to content

Commit 7fd3c56

Browse files
Reeywhaarumputun
authored andcommitted
add focus style to sort select
1 parent 82d1969 commit 7fd3c56

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.auth-panel__select-label-value_focused {
2+
outline: 1px dotted;
3+
outline-color: inherit;
4+
5+
@supports (outline-color: -webkit-focus-ring-color) {
6+
outline-color: -webkit-focus-ring-color;
7+
outline-style: auto;
8+
}
9+
}

frontend/app/components/auth-panel/auth-panel.tsx

+22-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ interface State {
3939
isBlockedVisible: boolean;
4040
anonymousUsernameInputValue: string;
4141
threshold: number;
42+
sortSelectFocused: boolean;
4243
}
4344

4445
export class AuthPanel extends Component<Props, State> {
@@ -51,6 +52,7 @@ export class AuthPanel extends Component<Props, State> {
5152
isBlockedVisible: false,
5253
anonymousUsernameInputValue: 'anon',
5354
threshold: 3,
55+
sortSelectFocused: false,
5456
};
5557

5658
this.toggleBlockedVisibility = this.toggleBlockedVisibility.bind(this);
@@ -91,6 +93,16 @@ export class AuthPanel extends Component<Props, State> {
9193
}
9294
}
9395

96+
onSortFocus = () => {
97+
this.setState({ sortSelectFocused: true });
98+
};
99+
100+
onSortBlur = (e: Event) => {
101+
this.setState({ sortSelectFocused: false });
102+
103+
this.onSortChange(e);
104+
};
105+
94106
toggleBlockedVisibility() {
95107
if (!this.state.isBlockedVisible) {
96108
if (this.props.onBlockedUsersShow) this.props.onBlockedUsersShow();
@@ -336,13 +348,21 @@ export class AuthPanel extends Component<Props, State> {
336348

337349
renderSort = () => {
338350
const { sort } = this.props;
351+
const { sortSelectFocused } = this.state;
339352
const sortArray = getSortArray(sort);
340353
return (
341354
<span className="auth-panel__sort">
342355
Sort by{' '}
343356
<span className="auth-panel__select-label">
344-
{sortArray.find(x => 'selected' in x && x.selected!)!.label}
345-
<select className="auth-panel__select" onChange={this.onSortChange} onBlur={this.onSortChange}>
357+
<span className={b('auth-panel__select-label-value', {}, { focused: sortSelectFocused })}>
358+
{sortArray.find(x => 'selected' in x && x.selected!)!.label}
359+
</span>
360+
<select
361+
className="auth-panel__select"
362+
onChange={this.onSortChange}
363+
onFocus={this.onSortFocus}
364+
onBlur={this.onSortBlur}
365+
>
346366
{sortArray.map(sort => (
347367
<option value={sort.value} selected={sort.selected}>
348368
{sort.label}

frontend/app/components/auth-panel/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require('./__column/auth-panel__column.scss');
88
require('./__pseudo-link/auth-panel__pseudo-link.scss');
99
require('./__select/auth-panel__select.scss');
1010
require('./__select-label/auth-panel__select-label.scss');
11+
require('./__select-label-value/auth-panel__select-label-value.scss');
1112
require('./__sort/auth-panel__sort.scss');
1213

1314
require('./__user-id/auth-panel__user-id.scss');

0 commit comments

Comments
 (0)