Skip to content

Commit

Permalink
add quick search in mobile layout (#2360)
Browse files Browse the repository at this point in the history
Co-authored-by: jasongwq <[email protected]>
  • Loading branch information
jasongwq and jasongwq authored Nov 20, 2021
1 parent 7a383a1 commit db9e35a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/public/app/layouts/mobile_layout.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FlexContainer from "../widgets/containers/flex_container.js";
import NoteTitleWidget from "../widgets/note_title.js";
import NoteDetailWidget from "../widgets/note_detail.js";
import QuickSearchWidget from "../widgets/quick_search.js";
import NoteTreeWidget from "../widgets/note_tree.js";
import MobileGlobalButtonsWidget from "../widgets/mobile_widgets/mobile_global_buttons.js";
import CloseDetailButtonWidget from "../widgets/mobile_widgets/close_detail_button.js";
Expand All @@ -27,13 +28,19 @@ kbd {
padding-right: 0.5em;
color: var(--main-text-color);
}
.quick-search {
margin: 55px 0px 0px 0px;
}
.quick-search .dropdown-menu {
max-width: 350px;
}
</style>`;

const FANCYTREE_CSS = `
<style>
.tree-wrapper {
max-height: 100%;
margin-top: 55px;
margin-top: 0px;
overflow-y: auto;
contain: content;
padding-left: 10px;
Expand Down Expand Up @@ -95,6 +102,7 @@ export default class MobileLayout {
.css('padding-left', 0)
.css('contain', 'content')
.child(new MobileGlobalButtonsWidget())
.child(new QuickSearchWidget())
.child(new NoteTreeWidget("main")
.cssBlock(FANCYTREE_CSS)))
.child(new ScreenContainer("detail", "column")
Expand Down
14 changes: 14 additions & 0 deletions src/public/app/widgets/quick_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ export default class QuickSearchWidget extends BasicWidget {

this.$widget.find('.input-group-prepend').on('shown.bs.dropdown', () => this.search());

if(utils.isMobile()) {
this.$searchString.keydown(e =>{
if(e.which==13) {
if (this.$dropdownMenu.is(":visible")) {
this.search(); // just update already visible dropdown
} else {
this.$dropdownToggle.dropdown('show');
}
e.preventDefault();
e.stopPropagation();
}
})
}

utils.bindElShortcut(this.$searchString, 'return', () => {
if (this.$dropdownMenu.is(":visible")) {
this.search(); // just update already visible dropdown
Expand Down

0 comments on commit db9e35a

Please sign in to comment.