Skip to content

Commit

Permalink
FIX: Search input focus 2024.3 (#2552)
Browse files Browse the repository at this point in the history
* requestFocus function used in more places
* Revert "ModalWindow was moved after displayed"
  • Loading branch information
JindrichSusen committed Mar 27, 2024
1 parent 8aff6f7 commit e6add90
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 17 deletions.
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
3 changes: 2 additions & 1 deletion frontend-html/src/gui/Components/Dialogs/YesNoQuestion.tsx
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

0 comments on commit e6add90

Please sign in to comment.