mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 01:52:42 +03:00
interface: track suspended element when leap loads
This commit is contained in:
parent
54a7acbfc2
commit
494275b6ab
@ -3,7 +3,7 @@ import { StoreState } from '../../store/type';
|
|||||||
import { Cage } from '../../types/cage';
|
import { Cage } from '../../types/cage';
|
||||||
import { LocalUpdate } from '../../types/local-update';
|
import { LocalUpdate } from '../../types/local-update';
|
||||||
|
|
||||||
type LocalState = Pick<StoreState, 'sidebarShown' | 'omniboxShown' | 'dark' | 'baseHash'>;
|
type LocalState = Pick<StoreState, 'sidebarShown' | 'omniboxShown' | 'dark' | 'baseHash' | 'suspendedFocus'>;
|
||||||
|
|
||||||
export default class LocalReducer<S extends LocalState> {
|
export default class LocalReducer<S extends LocalState> {
|
||||||
reduce(json: Cage, state: S) {
|
reduce(json: Cage, state: S) {
|
||||||
@ -24,6 +24,13 @@ export default class LocalReducer<S extends LocalState> {
|
|||||||
omniboxShown(obj: LocalUpdate, state: S) {
|
omniboxShown(obj: LocalUpdate, state: S) {
|
||||||
if ('omniboxShown' in obj) {
|
if ('omniboxShown' in obj) {
|
||||||
state.omniboxShown = !state.omniboxShown;
|
state.omniboxShown = !state.omniboxShown;
|
||||||
|
if (state.suspendedFocus) {
|
||||||
|
state.suspendedFocus.focus();
|
||||||
|
state.suspendedFocus = null;
|
||||||
|
} else {
|
||||||
|
state.suspendedFocus = document.activeElement;
|
||||||
|
document.activeElement?.blur();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
|||||||
connection: 'connected',
|
connection: 'connected',
|
||||||
sidebarShown: true,
|
sidebarShown: true,
|
||||||
omniboxShown: false,
|
omniboxShown: false,
|
||||||
|
suspendedFocus: null,
|
||||||
baseHash: null,
|
baseHash: null,
|
||||||
invites: {},
|
invites: {},
|
||||||
associations: {
|
associations: {
|
||||||
|
@ -16,6 +16,7 @@ export interface StoreState {
|
|||||||
// local state
|
// local state
|
||||||
sidebarShown: boolean;
|
sidebarShown: boolean;
|
||||||
omniboxShown: boolean;
|
omniboxShown: boolean;
|
||||||
|
suspendedFocus: HTMLInputElement | null;
|
||||||
dark: boolean;
|
dark: boolean;
|
||||||
connection: ConnectionStatus;
|
connection: ConnectionStatus;
|
||||||
baseHash: string | null;
|
baseHash: string | null;
|
||||||
|
@ -80,8 +80,11 @@ render() {
|
|||||||
{this.props.prompt}
|
{this.props.prompt}
|
||||||
</span>
|
</span>
|
||||||
<input
|
<input
|
||||||
autoCorrect="false"
|
autocorrect="off"
|
||||||
autoFocus={true}
|
autocapitalize="off"
|
||||||
|
spellcheck="false"
|
||||||
|
tabindex="0"
|
||||||
|
wrap="off"
|
||||||
className="mono ml1 flex-auto dib w-100"
|
className="mono ml1 flex-auto dib w-100"
|
||||||
id="dojo"
|
id="dojo"
|
||||||
cursor={this.props.cursor}
|
cursor={this.props.cursor}
|
||||||
|
Loading…
Reference in New Issue
Block a user