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();
|
toNextOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onClear = () => {
|
||||||
|
setSearch("");
|
||||||
|
}
|
||||||
|
|
||||||
|
const onKeyDown = (evt: React.KeyboardEvent<any>) => {
|
||||||
|
if (evt.key === "Enter") {
|
||||||
|
onNextOverlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Refresh search when logs changed
|
// Refresh search when logs changed
|
||||||
searchStore.onSearch(logs);
|
searchStore.onSearch(logs);
|
||||||
@ -52,6 +62,8 @@ export const PodLogSearch = observer((props: PodLogSearchProps) => {
|
|||||||
onChange={setSearch}
|
onChange={setSearch}
|
||||||
closeIcon={false}
|
closeIcon={false}
|
||||||
contentRight={totalFinds > 0 && findCounts}
|
contentRight={totalFinds > 0 && findCounts}
|
||||||
|
onClear={onClear}
|
||||||
|
onKeyDown={onKeyDown}
|
||||||
/>
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
material="keyboard_arrow_up"
|
material="keyboard_arrow_up"
|
||||||
@ -68,7 +80,7 @@ export const PodLogSearch = observer((props: PodLogSearchProps) => {
|
|||||||
<Icon
|
<Icon
|
||||||
material="close"
|
material="close"
|
||||||
tooltip={_i18n._(t`Clear`)}
|
tooltip={_i18n._(t`Clear`)}
|
||||||
onClick={() => setSearch("")}
|
onClick={onClear}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -214,6 +214,10 @@ export class Input extends React.Component<InputProps, State> {
|
|||||||
onKeyDown(evt: React.KeyboardEvent<any>) {
|
onKeyDown(evt: React.KeyboardEvent<any>) {
|
||||||
const modified = evt.shiftKey || evt.metaKey || evt.altKey || evt.ctrlKey;
|
const modified = evt.shiftKey || evt.metaKey || evt.altKey || evt.ctrlKey;
|
||||||
|
|
||||||
|
if (this.props.onKeyDown) {
|
||||||
|
this.props.onKeyDown(evt);
|
||||||
|
}
|
||||||
|
|
||||||
switch (evt.key) {
|
switch (evt.key) {
|
||||||
case "Enter":
|
case "Enter":
|
||||||
if (this.props.onSubmit && !modified && !evt.repeat) {
|
if (this.props.onSubmit && !modified && !evt.repeat) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user