Skip to content

Commit 77b8056

Browse files
authored
Keep cursor in search box when adjusting filters (JuliaDocs#2661)
1 parent 4e8bed3 commit 77b8056

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
# Unreleased
7+
8+
## Changed
9+
10+
* Now the cursor remain focused on search box even after selecting the filter. ([#2410])
11+
612
## Version [v1.9.0] - 2025-03-17
713

814
### Added
@@ -1924,6 +1930,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
19241930
[#2394]: https://github.com/JuliaDocs/Documenter.jl/issues/2394
19251931
[#2406]: https://github.com/JuliaDocs/Documenter.jl/issues/2406
19261932
[#2408]: https://github.com/JuliaDocs/Documenter.jl/issues/2408
1933+
[#2410]: https://github.com/JuliaDocs/Documenter.jl/issues/2410
19271934
[#2414]: https://github.com/JuliaDocs/Documenter.jl/issues/2414
19281935
[#2415]: https://github.com/JuliaDocs/Documenter.jl/issues/2415
19291936
[#2424]: https://github.com/JuliaDocs/Documenter.jl/issues/2424

assets/html/js/search.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ function runSearchMainCode() {
463463
};
464464

465465
$(document).on("click", ".search-filter", function () {
466+
let search_input = $(".documenter-search-input");
467+
let cursor_position = search_input[0].selectionStart;
468+
466469
if ($(this).hasClass("search-filter-selected")) {
467470
selected_filter = "";
468471
} else {
@@ -471,6 +474,9 @@ function runSearchMainCode() {
471474

472475
// This updates search results and toggles classes for UI:
473476
update_search();
477+
478+
search_input.focus();
479+
search_input.setSelectionRange(cursor_position, cursor_position);
474480
});
475481

476482
/**

0 commit comments

Comments
 (0)