diff --git a/src/pyj/book_list/library_data.pyj b/src/pyj/book_list/library_data.pyj index 9dc419d7d1..3f20f4f22f 100644 --- a/src/pyj/book_list/library_data.pyj +++ b/src/pyj/book_list/library_data.pyj @@ -25,6 +25,7 @@ def url_books_query(sd): return { 'library_id': lid, 'sort': q.sort or sd.get_library_option(lid, 'sort'), + 'search': q.search, } @@ -36,6 +37,7 @@ def loaded_books_query(): return { 'library_id': sr.library_id if sr else None, 'sort': sort, + 'search': sr?.query } diff --git a/src/pyj/book_list/search.pyj b/src/pyj/book_list/search.pyj index c0621f3077..3ab69efd57 100644 --- a/src/pyj/book_list/search.pyj +++ b/src/pyj/book_list/search.pyj @@ -70,9 +70,10 @@ def node_for_path(path): def execute_search(text): - container = document.getElementById(state.container_id) - search_control = container.querySelector('input[name="search-books"]') - text = text or search_control.value or '' + if not text: + container = document.getElementById(state.container_id) + search_control = container.querySelector('input[name="search-books"]') + text = search_control.value or '' apply_search(text) @@ -122,8 +123,7 @@ def search_expression_for_item(node, node_state): rnum = '{}.5'.format(rnum - 1) expr = '{}:{}'.format(category, rnum) else: - interface_data = get_interface_data() - fm = interface_data.field_metadata[item.category] + fm = library_data.field_metadata[item.category] suffix = ':' if fm and fm.is_csp else '' name = item.original_name or item.name or item.sort if not name: @@ -274,8 +274,8 @@ def render_children(container, children): ) ) set_css(div, max_width='45vw', border='solid 1px currentColor', border_radius='20px', margin='0.5rem', cursor='pointer', overflow='hidden', user_select='none') - div.firstChild.addEventListener('click', node_clicked.bind(i)) - div.lastChild.addEventListener('click', menu_clicked.bind(i)) + div.firstChild.addEventListener('click', node_clicked.bind(None, i)) + div.lastChild.addEventListener('click', menu_clicked.bind(None, i)) container.appendChild(div) def render_breadcrumbs(): @@ -333,12 +333,12 @@ def on_data_fetched(end_type, xhr, ev): container.appendChild(ediv) ediv.innerHTML = '