-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #775 from City-of-Helsinki/UHF-8839_Search_focus
UHF-8839: Search focus
- Loading branch information
Showing
6 changed files
with
44 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(function ($) { | ||
|
||
// Set focus on search result count | ||
$(document).ajaxComplete(function onDataLoaded(e, xhr, settings) { | ||
// Check form ID to prevent mixing on multi-form page | ||
const viewDomId = settings.extraData.view_dom_id; | ||
const resultsContainerEl = $(`[data-id-number=${ viewDomId }]`); | ||
const resultCountEl = $('[class$="__count-container"]', resultsContainerEl[0])[0]; | ||
|
||
if (!resultCountEl) return; | ||
resultCountEl.setAttribute('tabindex', '-1'); | ||
resultCountEl.focus(); | ||
resultCountEl.scrollIntoView({behavior: 'smooth', block: 'center'}); | ||
}); | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters