fix(theme/book): Workaround focusout bug in macOS and iOS (#630)
This commit is contained in:
parent
38c883e1ef
commit
82aef1bc3f
|
@ -372,7 +372,15 @@ function playpen_text(playpen) {
|
||||||
});
|
});
|
||||||
|
|
||||||
themePopup.addEventListener('focusout', function(e) {
|
themePopup.addEventListener('focusout', function(e) {
|
||||||
if (!themePopup.contains(e.relatedTarget)) {
|
// e.relatedTarget is null in Safari and Firefox on macOS (see workaround below)
|
||||||
|
if (!!e.relatedTarget && !themePopup.contains(e.relatedTarget)) {
|
||||||
|
hideThemes();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang-nursery/mdBook/issues/628
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
if (themePopup.style.display === 'block' && !themeToggleButton.contains(e.target) && !themePopup.contains(e.target)) {
|
||||||
hideThemes();
|
hideThemes();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue