Skip to content

Commit

Permalink
improvement: outline keyboard-focused elements
Browse files Browse the repository at this point in the history
This improves keyboard usage experience (accessibility, a11y)

For the most part this does not affect items
that are focused with mouse instead of keyboard
(apart from "advanced" login fields, and maybe some other places),
all thanks to `:focus-visible` selector
https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible#focus_vs_focus-visible

Composer, message search, settings, contact search are not affected
for pointer device users.

For reference, here are some commits that had to do with
`outline` and `:focus`.
They don't appear to be paying much attention
to keyboard-accessibility:
- b740c60
- b5fb8a0
- 0c7949c
- 11bda12
- 9307958
  • Loading branch information
WofWca authored and Simon-Laux committed Jul 18, 2024
1 parent c9a61e3 commit 1e86e9e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added
- New keyboard shortcuts (experimental setting): Telegram-style Ctrl+Up/Down to select the message to reply to #3965
- More shortcuts to switch between chats: `Ctrl + PageDown`, `Ctrl + PageUp`, `Ctrl + Tab`, `Ctrl + Shift + Tab` #3984
- Better keyboard accessibility: make more elements focusable, add outline them #4005

### Changed
- reword advanced setting "Disable Background Sync For All Accounts" -> "Only Synchronize the Currently Selected Account" #3960
Expand Down
15 changes: 7 additions & 8 deletions scss/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ a {

$unread-badge-size: 21px;

// Let's not add `:not(:focus-visible)` since the blinking cursor
// might be enough, (or it might not, we'll see).
input:focus {
outline: none;
}

input[type='text'],
input[type='search'],
textarea {
Expand All @@ -80,15 +86,8 @@ textarea {
}
}

input:focus {
outline: 0 !important;
}

//yellow/blue border fix
button:focus {
outline: none;
}
button:focus {
button:focus:not(:focus-visible) {
outline: none;
}

Expand Down
10 changes: 6 additions & 4 deletions scss/composer/_composer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@
background: none;
cursor: pointer;
}
&:focus {
&:focus:not(:focus-visible) {
outline: none;
}
}

.emoji-button {
height: 40px;
padding: 0px 3px;
&:focus {
&:focus:not(:focus-visible) {
outline: none;
}
&:hover {
Expand All @@ -111,7 +111,7 @@
border-radius: 180px;
cursor: pointer;

&:focus {
&:focus:not(:focus-visible) {
outline: none;
}

Expand All @@ -127,7 +127,7 @@
background-size: contain;
vertical-align: middle;

&:focus {
&:focus:not(:focus-visible) {
outline: none;
}
}
Expand All @@ -150,6 +150,8 @@
color: var(--composerPlaceholderText);
}

// Let's not add `:not(:focus-visible)` since the blinking cursor
// might be enough, (or it might not, we'll see).
&:focus {
outline: none;
}
Expand Down
7 changes: 4 additions & 3 deletions scss/manifest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
@import '../node_modules/@blueprintjs/icons/lib/css/blueprint-icons.css';
@import '../node_modules/@blueprintjs/core/lib/css/blueprint.css';

// Overwrites for third party node modules.
// Above our styles, so that our styles take priority by being defined after.
@import 'overwrites/_bp4-overwrites';

// Global Settings, Variables, and Mixins
@import 'variables';
@import 'mixins';
Expand Down Expand Up @@ -68,9 +72,6 @@
@import 'misc/_keyboard_hint_box.scss';
@import 'misc/_search-input.scss';

// Overwrites for third party node modules
@import 'overwrites/_bp4-overwrites';

// ConnectivityToast
@import '_connectivity-toast';

Expand Down
3 changes: 2 additions & 1 deletion scss/overwrites/_bp4-overwrites.scss
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@
.bp4-control input:focus ~ .bp4-control-indicator,
input[type='text']:active,
input[type='text']:focus {
outline: unset;
outline: revert;
outline-offset: revert;
}

.bp4-spinner-animation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
border: 0;
height: 42px;
margin: 0;
outline: 0;
padding: 0;
width: 42px;

Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/ImageSelector/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
height: 35px;
justify-content: center;
margin: 0;
outline: 0;
padding: 0;
position: absolute;
right: 0;
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/QrReader/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.2));
height: 35px;
margin: 15px;
outline: 0;
padding: 5px;
position: absolute;
right: 5px;
Expand Down

0 comments on commit 1e86e9e

Please sign in to comment.