From 0b43eaa992ac209f9f20c14ccf4ed0bd140bd55a Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 18 Jun 2018 22:44:55 -0400 Subject: [PATCH] blur active element on navigation - fixes #287 --- src/runtime/index.ts | 1 + test/common/test.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/runtime/index.ts b/src/runtime/index.ts index 9575b74..e890bcf 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -161,6 +161,7 @@ function navigate(target: Target, id: number) { } render(Page, props, scroll_history[id], token); + document.activeElement.blur(); }); } diff --git a/test/common/test.js b/test/common/test.js index 19028dc..3c637eb 100644 --- a/test/common/test.js +++ b/test/common/test.js @@ -608,6 +608,19 @@ function run({ mode, basepath = '' }) { it('emits a basepath', () => { assert.equal(captured_basepath, basepath); }); + + // skipped because Nightmare doesn't seem to focus the correctly + it.skip('resets the active element after navigation', () => { + return nightmare + .goto(base) + .init() + .click('a[href="about"]') + .wait(100) + .evaluate(() => document.activeElement.nodeName) + .then(name => { + assert.equal(name, 'BODY'); + }); + }); }); describe('headers', () => {