mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Search command should re-focus search box if already open (#164)
Some checks failed
CodeQL / Analyze (push) Has been cancelled
Some checks failed
CodeQL / Analyze (push) Has been cancelled
This commit is contained in:
parent
d65dfba445
commit
fa460d697c
6 changed files with 18 additions and 7 deletions
|
|
@ -141,7 +141,7 @@ export function openSearch(uid?: string) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: SESSION_SEARCH,
|
type: SESSION_SEARCH,
|
||||||
uid: targetUid,
|
uid: targetUid,
|
||||||
value: true
|
value: new Date()
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +153,7 @@ export function closeSearch(uid?: string, keyEvent?: any) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: SESSION_SEARCH,
|
type: SESSION_SEARCH,
|
||||||
uid: targetUid,
|
uid: targetUid,
|
||||||
value: false
|
value: null
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (keyEvent) {
|
if (keyEvent) {
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ const SearchButton = ({
|
||||||
const SearchBox = forwardRef<HTMLDivElement, SearchBoxProps>((props, ref) => {
|
const SearchBox = forwardRef<HTMLDivElement, SearchBoxProps>((props, ref) => {
|
||||||
const {
|
const {
|
||||||
caseSensitive,
|
caseSensitive,
|
||||||
|
dateFocused,
|
||||||
wholeWord,
|
wholeWord,
|
||||||
regex,
|
regex,
|
||||||
results,
|
results,
|
||||||
|
|
@ -122,6 +123,14 @@ const SearchBox = forwardRef<HTMLDivElement, SearchBoxProps>((props, ref) => {
|
||||||
inputRef.current?.focus();
|
inputRef.current?.focus();
|
||||||
}, [inputRef.current]);
|
}, [inputRef.current]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!dateFocused) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inputRef.current?.focus();
|
||||||
|
inputRef.current?.select();
|
||||||
|
}, [dateFocused]);
|
||||||
|
|
||||||
const searchButtonColors: SearchButtonColors = {
|
const searchButtonColors: SearchButtonColors = {
|
||||||
backgroundColor: borderColor,
|
backgroundColor: borderColor,
|
||||||
selectionColor,
|
selectionColor,
|
||||||
|
|
|
||||||
|
|
@ -518,6 +518,7 @@ export default class Term extends React.PureComponent<
|
||||||
{this.props.customChildren}
|
{this.props.customChildren}
|
||||||
{this.props.search ? (
|
{this.props.search ? (
|
||||||
<SearchBox
|
<SearchBox
|
||||||
|
dateFocused={this.props.search}
|
||||||
next={this.searchNext}
|
next={this.searchNext}
|
||||||
prev={this.searchPrevious}
|
prev={this.searchPrevious}
|
||||||
close={this.closeSearchBox}
|
close={this.closeSearchBox}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ function Session(obj: Immutable.DeepPartial<session>) {
|
||||||
cols: null,
|
cols: null,
|
||||||
rows: null,
|
rows: null,
|
||||||
cleared: false,
|
cleared: false,
|
||||||
search: false,
|
search: null,
|
||||||
shell: '',
|
shell: '',
|
||||||
pid: null,
|
pid: null,
|
||||||
profile: ''
|
profile: ''
|
||||||
|
|
|
||||||
2
typings/constants/sessions.d.ts
vendored
2
typings/constants/sessions.d.ts
vendored
|
|
@ -74,7 +74,7 @@ export interface SessionSetCwdAction {
|
||||||
export interface SessionSearchAction {
|
export interface SessionSearchAction {
|
||||||
type: typeof SESSION_SEARCH;
|
type: typeof SESSION_SEARCH;
|
||||||
uid: string;
|
uid: string;
|
||||||
value: boolean;
|
value: Date | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SessionActions =
|
export type SessionActions =
|
||||||
|
|
|
||||||
7
typings/hyper.d.ts
vendored
7
typings/hyper.d.ts
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||||
/* eslint-disable import/order */
|
/* eslint-disable import/order */
|
||||||
import type {Immutable} from 'seamless-immutable';
|
import type {Immutable, ImmutableDate} from 'seamless-immutable';
|
||||||
import type Client from '../lib/utils/rpc';
|
import type Client from '../lib/utils/rpc';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|
@ -118,7 +118,7 @@ export type session = {
|
||||||
pid: number | null;
|
pid: number | null;
|
||||||
resizeAt?: number;
|
resizeAt?: number;
|
||||||
rows: number | null;
|
rows: number | null;
|
||||||
search: boolean;
|
search: ImmutableDate | null;
|
||||||
shell: string | null;
|
shell: string | null;
|
||||||
title: string;
|
title: string;
|
||||||
uid: string;
|
uid: string;
|
||||||
|
|
@ -326,6 +326,7 @@ import type {TermGroupConnectedProps} from '../lib/components/term-group';
|
||||||
export type TermGroupProps = TermGroupConnectedProps & TermGroupOwnProps;
|
export type TermGroupProps = TermGroupConnectedProps & TermGroupOwnProps;
|
||||||
|
|
||||||
export type SearchBoxProps = {
|
export type SearchBoxProps = {
|
||||||
|
dateFocused: ImmutableDate | null;
|
||||||
caseSensitive: boolean;
|
caseSensitive: boolean;
|
||||||
wholeWord: boolean;
|
wholeWord: boolean;
|
||||||
regex: boolean;
|
regex: boolean;
|
||||||
|
|
@ -386,7 +387,7 @@ export type TermProps = {
|
||||||
rows: number | null;
|
rows: number | null;
|
||||||
screenReaderMode: boolean;
|
screenReaderMode: boolean;
|
||||||
scrollback: number;
|
scrollback: number;
|
||||||
search: boolean;
|
search: ImmutableDate | null;
|
||||||
searchAddon: SearchAddon | null;
|
searchAddon: SearchAddon | null;
|
||||||
selectionColor: string;
|
selectionColor: string;
|
||||||
term: Terminal | null;
|
term: Terminal | null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue