Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only blur the focused element if it is inside Pjax container #25

Merged
merged 1 commit into from Nov 19, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions jquery.pjax.js
Expand Up @@ -303,10 +303,15 @@ function pjax(options) {
window.history.replaceState(pjax.state, container.title, container.url)
}

// Only blur the focus if the focused element is within the container.
var blurFocus = $.contains(options.container, document.activeElement)

// Clear out any focused controls before inserting new page contents.
try {
document.activeElement.blur()
} catch (e) { }
if (blurFocus) {
try {
document.activeElement.blur()
} catch (e) { }
}

if (container.title) document.title = container.title

Expand Down