Fix button focus highlight on Windows (#1627)

* Fix button focus highlight on Windows

* Use none instead of none for outline and box-shadow

* Unnest selectors in reviewer-bottom

Co-authored-by: Henrik Giesel <hengiesel@gmail.com>
This commit is contained in:
RumovZ 2022-02-07 10:41:19 +01:00 committed by GitHub
parent 0c81bbce04
commit f61126a40c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 9 deletions

View file

@ -49,15 +49,25 @@ button {
margin-bottom: 1em;
}
.focus {
outline: 5px auto var(--focus-color);
#innertable:focus-within & {
outline: unset;
/**
* We use .focus to recreate the highlight on the good button
* while the actual focus is actually in the main webview
*/
:focus, .focus {
outline: 1px auto var(--focus-color);
&:focus {
outline: 5px auto var(--focus-color);
}
.nightMode & {
outline: none;
box-shadow: 0 0 0 2px var(--focus-color);
}
}
#innertable:focus-within .focus:not(:focus) {
outline: none;
.nightMode & {
box-shadow: none;
}
}

View file

@ -413,8 +413,9 @@ class AnkiWebView(QWebEngineView):
if is_win:
# T: include a font for your language on Windows, eg: "Segoe UI", "MS Mincho"
family = tr.qt_misc_segoe_ui()
button_style = "button { font-family:%s; }" % family
button_style += "\n:focus { outline: 1px solid %s; }" % color_hl
button_style = f"""
button {{ font-family: {family}; }}
button:focus {{ outline: 5px auto {color_hl}; }}"""
font = f"font-size:12px;font-family:{family};"
elif is_mac:
family = "Helvetica"

View file

@ -1,5 +1,13 @@
@use "fusion-vars";
:root {
--focus-color: #0078d7;
.isMac {
--focus-color: rgba(0 103 244 / 0.247);
}
}
.isWin {
button {
font-size: 12px;
@ -39,6 +47,11 @@
border-radius: 5px;
padding: 3px 10px 3px;
&:focus {
outline: none;
box-shadow: 0 0 0 2px var(--focus-color);
}
}
button:hover {