Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Search input focus 2024.3 #2552

Merged
merged 4 commits into from Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,6 +22,7 @@ import React from "react";
import CS from "./DialogsCommon.module.css";
import { T } from "../../../utils/translation";
import { ModalDialog } from "gui/Components/Dialog/ModalDialog";
import { requestFocus } from "utils/focus";

@observer
export class ChangeMasterRecordDialog extends React.Component<{
Expand All @@ -36,7 +37,7 @@ export class ChangeMasterRecordDialog extends React.Component<{
componentDidMount() {
setTimeout(() => {
if (this.elmPrimaryBtn) {
this.elmPrimaryBtn.focus?.();
requestFocus(this.elmPrimaryBtn);
}
}, 159);
}
Expand Down
11 changes: 0 additions & 11 deletions frontend-html/src/gui/Components/Dialogs/ModalWindow.tsx
Expand Up @@ -61,30 +61,20 @@ export class ModalWindow extends React.Component<{
return this._left;
}
@observable isDragging = false;
@observable
isHidden = true;

reportingWindowMove = false;
dragStartMouseX = 0;
dragStartMouseY = 0;
dragStartPosX = 0;
dragStartPosY = 0;

timeout: NodeJS.Timeout | undefined;
contentRect?: { bounds: BoundingRect };

@action.bound handleResize(contentRect: { bounds: BoundingRect }) {
if (this.props.topPosiotionProc) {
this.top = window.innerHeight * this.props.topPosiotionProc / 100;
} else {
this.top = window.innerHeight / 2 - contentRect.bounds!.height / 2;
}
this.left = window.innerWidth / 2 - contentRect.bounds!.width / 2;

clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
this.isHidden = false;
}, 20);
}

@action.bound handleTitleMouseDown(event: any) {
Expand Down Expand Up @@ -193,7 +183,6 @@ export class ModalWindow extends React.Component<{
left: this.props.fullScreen ? 0 : this.left,
minWidth: this.props.fullScreen ? "100%" : this.props.width,
minHeight: this.props.fullScreen ? "100%" : this.props.height,
visibility: this.isHidden ? "hidden" : undefined
}}
tabIndex={0}
onKeyDown={(event: any) => this.onKeyDown(event)}
Expand Down
Expand Up @@ -22,6 +22,7 @@ import { observer } from "mobx-react";
import CS from "./DialogsCommon.module.css";
import { T } from "../../../utils/translation";
import { ModalDialog } from "gui/Components/Dialog/ModalDialog";
import { requestFocus } from "utils/focus";

@observer
export class QuestionLogoutWithDirtyData extends React.Component<{
Expand All @@ -34,7 +35,7 @@ export class QuestionLogoutWithDirtyData extends React.Component<{
componentDidMount() {
setTimeout(() => {
if (this.elmPrimaryBtn) {
this.elmPrimaryBtn.focus?.();
requestFocus(this.elmPrimaryBtn);
}
}, 150);
}
Expand Down
Expand Up @@ -22,6 +22,7 @@ import { observer } from "mobx-react";
import CS from "./DialogsCommon.module.css";
import { T } from "../../../utils/translation";
import { ModalDialog } from "gui/Components/Dialog/ModalDialog";
import { requestFocus } from "utils/focus";

@observer
export class QuestionSaveData extends React.Component<{
Expand All @@ -36,7 +37,7 @@ export class QuestionSaveData extends React.Component<{
componentDidMount() {
setTimeout(() => {
if (this.elmPrimaryBtn) {
this.elmPrimaryBtn.focus?.();
requestFocus(this.elmPrimaryBtn);
}
}, 150);
}
Expand Down
Expand Up @@ -21,6 +21,7 @@ import { MobXProviderContext, observer } from "mobx-react";
import React from "react";
import CS from "gui/Components/Dialogs/DialogsCommon.module.css";
import { ModalDialog } from "gui/Components/Dialog/ModalDialog";
import { requestFocus } from "utils/focus";

@observer
export class YesNoQuestion extends React.Component<{
Expand All @@ -38,7 +39,7 @@ export class YesNoQuestion extends React.Component<{
componentDidMount() {
setTimeout(() => {
if (this.elmPrimaryBtn) {
this.elmPrimaryBtn.focus?.();
requestFocus(this.elmPrimaryBtn);
}
}, 150);
}
Expand Down
Expand Up @@ -102,7 +102,7 @@ export const TagInputEditor = inject(({property}: { property: IProperty }, {valu
beh.subscribeToFocusManager(beh.elmInputElement);
}
if (props.autoFocus) {
setTimeout(() => inputElement?.focus());
setTimeout(() => requestFocus(inputElement));
}
}, [beh, inputElement, props.autoFocus]);

Expand Down
2 changes: 1 addition & 1 deletion frontend-html/src/model/entities/FormFocusManager.ts
Expand Up @@ -90,7 +90,7 @@ export class FormFocusManager {
forceAutoFocus() {
if (this.focusableContainers.length === 0 && this.backupFocusPlaceholder) {
setTimeout(() => {
this.backupFocusPlaceholder?.focus();
requestFocus(this.backupFocusPlaceholder);
}, 0);
return;
}
Expand Down