Skip to content

Commit

Permalink
fix: search view hide not focus libro view
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanba authored and sunshinesmilelk committed Feb 22, 2024
1 parent bfede4d commit 4eeb626
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/libro-search/src/libro-search-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ export const SearchContent = () => {
icon={<EllipsisOutlined />}
size="small"
/>
<Button onClick={instance.hide} icon={<CloseOutlined />} size="small" />
<Button
onClick={() => instance.hide()}
icon={<CloseOutlined />}
size="small"
/>
</div>
</td>
</tr>
Expand Down Expand Up @@ -269,12 +273,13 @@ export class LibroSearchView extends BaseView {
this.toDispose.push(
this.libro.model.onCellViewChanged(() => this.onCellsChanged()),
);
// search view 失去焦点时依然可以通过esc隐藏search
this.toDispose.push(
this.libro.model.onCommandModeChanged((mode) => {
if (mode) {
setTimeout(() => {
if (this.hasFocus === false) {
this.hide();
this.hide(false);
}
}, 0);
}
Expand Down Expand Up @@ -306,14 +311,16 @@ export class LibroSearchView extends BaseView {
this.initialQuery();
this.findInputRef?.current?.focus();
};
hide = () => {
hide = (focus = true) => {
this.searchVisible = false;
this.contextKey.enableCommandMode();
this.searchProvider?.endQuery();
if (this.searchProvider) {
this.searchProvider.replaceMode = false;
}
this.libro?.focus();
if (focus) {
this.libro?.focus();
}
};

onFocus = () => {
Expand Down

0 comments on commit 4eeb626

Please sign in to comment.