1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add search bindings for 'Esc' & 'Enter' hits

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2020-10-26 11:10:46 +03:00
parent d736f24961
commit 2e2eec7195
2 changed files with 17 additions and 1 deletions

View File

@ -40,6 +40,16 @@ export const PodLogSearch = observer((props: PodLogSearchProps) => {
toNextOverlay();
}
const onClear = () => {
setSearch("");
}
const onKeyDown = (evt: React.KeyboardEvent<any>) => {
if (evt.key === "Enter") {
onNextOverlay();
}
}
useEffect(() => {
// Refresh search when logs changed
searchStore.onSearch(logs);
@ -52,6 +62,8 @@ export const PodLogSearch = observer((props: PodLogSearchProps) => {
onChange={setSearch}
closeIcon={false}
contentRight={totalFinds > 0 && findCounts}
onClear={onClear}
onKeyDown={onKeyDown}
/>
<Icon
material="keyboard_arrow_up"
@ -68,7 +80,7 @@ export const PodLogSearch = observer((props: PodLogSearchProps) => {
<Icon
material="close"
tooltip={_i18n._(t`Clear`)}
onClick={() => setSearch("")}
onClick={onClear}
/>
</div>
);

View File

@ -214,6 +214,10 @@ export class Input extends React.Component<InputProps, State> {
onKeyDown(evt: React.KeyboardEvent<any>) {
const modified = evt.shiftKey || evt.metaKey || evt.altKey || evt.ctrlKey;
if (this.props.onKeyDown) {
this.props.onKeyDown(evt);
}
switch (evt.key) {
case "Enter":
if (this.props.onSubmit && !modified && !evt.repeat) {