diff --git a/frontend/src/components/search/search.js b/frontend/src/components/search/search.js index a7cd7d3207..37e05f1d27 100644 --- a/frontend/src/components/search/search.js +++ b/frontend/src/components/search/search.js @@ -1,4 +1,5 @@ import React, { Component, Fragment } from 'react'; +import { Form, FormGroup, Input, Label } from 'reactstrap'; import PropTypes from 'prop-types'; import isHotkey from 'is-hotkey'; import MediaQuery from 'react-responsive'; @@ -100,7 +101,7 @@ class Search extends Component { // not chrome:compositionstart -> compositionend -> onChange // The onChange event will setState and change input value, then setTimeout to initiate the search setTimeout(() => { - this.onSearch(true); + this.onSearch(!this.props.isLibView || !enableSeafileAI); }, 1); }; @@ -272,10 +273,13 @@ class Search extends Component { this.updateSearchPageURL(queryData); queryData['per_page'] = PER_PAGE; queryData['page'] = page; - if (!enableSeafileAI || !this.props.isLibView) { - this.onNormalSearch(queryData, cancelToken, page); - } else { + if (enableSeafileAI && this.props.isLibView) { + queryData['search_filename_only'] = true; + } + if (enableSeafileAI && this.props.isLibView && this.state.indexState === INDEX_STATE.FINISHED) { this.onCombinedSearch(queryData, cancelToken, page); + } else { + this.onNormalSearch(queryData, cancelToken, page); } } }; @@ -479,23 +483,8 @@ class Search extends Component { } renderSearchResult() { - const { resultItems, highlightIndex, indexState, width } = this.state; + const { resultItems, highlightIndex, width } = this.state; if (!width || width === 'default') return null; - if (enableSeafileAI && indexState === INDEX_STATE.UNCREATED) { - return ( -