tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
177 stars 41 forks source link

Keyboard navigation breaks keyboard navigation #71

Closed gulumige closed 4 years ago

gulumige commented 4 years ago

Anytime passage navigation is triggered in any way other than a mouseclick, the outline highlighting the focused element is not visible until the page is again clicked on.

gulumige commented 4 years ago

I've been using this as a temporary fix. Thought it might clarify the problem. ~~ $(document).on("keydown", function (event) { if (event.keyCode === 9) $("#style-aria-outlines").empty(); }); ~~

(updated)

$(document).on("keydown.aria-outlines", function () {
    $("#style-aria-outlines").empty();
});
gulumige commented 4 years ago

Ok, so I think I have found what is causing the issue. If _lastOutlineEvent is set to "keydown" when entering a new passage no "keydown" events will show the outline. https://github.com/tmedwards/sugarcube-2/blob/ba1a16ec78896b4b2de6219292c579ce216eb049/src/engine.js#L127-L142 https://github.com/tmedwards/sugarcube-2/blob/ba1a16ec78896b4b2de6219292c579ce216eb049/src/engine.js#L639