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:
parent
d736f24961
commit
2e2eec7195
@ -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>
|
||||
);
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user