From 433a3697132ccc2e1cde79785d86b184a8a88506 Mon Sep 17 00:00:00 2001 From: Jindrich Susen Date: Wed, 31 May 2023 16:13:41 +0200 Subject: [PATCH 1/3] Grid was sometimes focused instead of the active input --- .../ScreenElements/Editors/NumberEditor.tsx | 2 +- .../Workbench/ScreenArea/TableView/TableView.tsx | 8 +++++++- .../ScreenArea/TableView/TableViewEditor.tsx | 9 +++++++-- .../FormScreenLifecycle/FormScreenLifecycle.tsx | 8 ++++---- .../src/model/entities/GridFocusManager.ts | 3 +++ frontend-html/yarn.lock | 14 -------------- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/frontend-html/src/gui/Components/ScreenElements/Editors/NumberEditor.tsx b/frontend-html/src/gui/Components/ScreenElements/Editors/NumberEditor.tsx index c9d8233a8e..a4670d62b9 100644 --- a/frontend-html/src/gui/Components/ScreenElements/Editors/NumberEditor.tsx +++ b/frontend-html/src/gui/Components/ScreenElements/Editors/NumberEditor.tsx @@ -48,7 +48,7 @@ export class NumberEditor extends React.Component<{ subscribeToFocusManager?: (obj: IFocusable, onBlur: ()=> Promise) => void; onTextOverflowChanged?: (toolTip: string | null | undefined) => void; id?: string -}> { +}, any> { state = { value: this.formatForDisplay(this.props.value), cursorPosition: 0}; disposer: undefined | (()=> void); inputRef = React.createRef(); diff --git a/frontend-html/src/gui/Workbench/ScreenArea/TableView/TableView.tsx b/frontend-html/src/gui/Workbench/ScreenArea/TableView/TableView.tsx index 227891de53..2dff8be78a 100644 --- a/frontend-html/src/gui/Workbench/ScreenArea/TableView/TableView.tsx +++ b/frontend-html/src/gui/Workbench/ScreenArea/TableView/TableView.tsx @@ -58,6 +58,7 @@ import { CtxDataView, DataViewContext } from "gui/Components/ScreenElements/Data import S from "./TableView.module.scss"; import { isMobileLayoutActive } from "model/selectors/isMobileLayoutActive"; import cx from "classnames"; +import { getGridFocusManager } from "model/entities/GridFocusManager"; interface ITableViewProps { dataView?: IDataView; @@ -107,7 +108,12 @@ export class TableViewInner extends React.Component { this.elmTable = elmTable; if (elmTable) { - const d1 = this.props.tablePanelView!.subOnFocusTable(elmTable.focusTable); + const d1 = this.props.tablePanelView!.subOnFocusTable(() => { + const gridFocusManager = getGridFocusManager(this.props.dataView); + if(gridFocusManager.canFocusTable){ + elmTable.focusTable(); + } + }); const d2 = this.props.tablePanelView!.subOnScrollToCellShortest( elmTable.scrollToCellShortest ); diff --git a/frontend-html/src/gui/Workbench/ScreenArea/TableView/TableViewEditor.tsx b/frontend-html/src/gui/Workbench/ScreenArea/TableView/TableViewEditor.tsx index 48ebc37c80..715becf270 100644 --- a/frontend-html/src/gui/Workbench/ScreenArea/TableView/TableViewEditor.tsx +++ b/frontend-html/src/gui/Workbench/ScreenArea/TableView/TableViewEditor.tsx @@ -62,7 +62,12 @@ import { CellAlignment } from "gui/Components/ScreenElements/Table/TableRenderin property: actualProperty, value: value, }), - onEditorBlur: async () => await onFieldBlur(tablePanelView)(), + onEditorBlur: async () => { + await onFieldBlur(tablePanelView)(); + const gridFocusManager = getGridFocusManager(tablePanelView); + gridFocusManager.activeEditor = undefined; + gridFocusManager.editorBlur = undefined; + }, onEditorKeyDown: (event: any) => { event.persist(); onFieldKeyDown(tablePanelView)(event); @@ -97,7 +102,7 @@ export class TableViewEditor extends React.Component<{ ? shadeHexColor(customBackgroundColor, -0.1) : customBackgroundColor; - const isFirsColumn = getTablePanelView(dataView).firstColumn === this.props.property; + const isFirsColumn = getTablePanelView(dataView)?.firstColumn === this.props.property; const gridFocusManager = getGridFocusManager(this.props.property); switch (this.props.property!.column) { case "Number": diff --git a/frontend-html/src/model/entities/FormScreenLifecycle/FormScreenLifecycle.tsx b/frontend-html/src/model/entities/FormScreenLifecycle/FormScreenLifecycle.tsx index 8bd30a9a68..ec83933275 100644 --- a/frontend-html/src/model/entities/FormScreenLifecycle/FormScreenLifecycle.tsx +++ b/frontend-html/src/model/entities/FormScreenLifecycle/FormScreenLifecycle.tsx @@ -402,7 +402,7 @@ export class FormScreenLifecycle02 implements IFormScreenLifecycle02 { return; } const rootDataView = rootDataViews[0]; - const filtersDisplayed = getTablePanelView(rootDataView).filterConfiguration + const filtersDisplayed = getTablePanelView(rootDataView)!.filterConfiguration .isFilterControlsDisplayed if(workFinished && !filtersDisplayed && rootDataView.isTableViewActive()){ rootDataView.formFocusManager.refocusLast(); @@ -1015,7 +1015,7 @@ export class FormScreenLifecycle02 implements IFormScreenLifecycle02 { formScreen.dataUpdateCRS.leave(); } yield*processCRUDResult(targetDataView, createObjectResult, false, targetDataView); - getTablePanelView(targetDataView).scrollToCurrentRow(); + getTablePanelView(targetDataView)!.scrollToCurrentRow(); } finally { this.monitor.inFlow--; } @@ -1194,7 +1194,7 @@ export class FormScreenLifecycle02 implements IFormScreenLifecycle02 { } async reloadAggregations(dataView: IDataView) { - const aggregations = getTablePanelView(dataView).aggregations.aggregationList; + const aggregations = getTablePanelView(dataView)!.aggregations.aggregationList; if (aggregations.length === 0) { dataView.aggregationData.length = 0; return; @@ -1398,7 +1398,7 @@ export class FormScreenLifecycle02 implements IFormScreenLifecycle02 { () => { const tablePanelView = getTablePanelView(dataView); const configurationManager = getConfigurationManager(tablePanelView); - configurationManager.activeTableConfiguration.apply(tablePanelView); + configurationManager.activeTableConfiguration.apply(tablePanelView!); }, {fireImmediately: true} ) diff --git a/frontend-html/src/model/entities/GridFocusManager.ts b/frontend-html/src/model/entities/GridFocusManager.ts index 7c0896d924..a6a63e68c8 100644 --- a/frontend-html/src/model/entities/GridFocusManager.ts +++ b/frontend-html/src/model/entities/GridFocusManager.ts @@ -7,6 +7,9 @@ import { requestFocus } from "utils/focus"; export class GridFocusManager { private _activeEditor: IFocusable | undefined; public focusTableOnReload: boolean = true; + get canFocusTable(){ + return !this._activeEditor; + } constructor(public parent: any) { } diff --git a/frontend-html/yarn.lock b/frontend-html/yarn.lock index 3ed6e2bef1..45286fd618 100644 --- a/frontend-html/yarn.lock +++ b/frontend-html/yarn.lock @@ -1935,15 +1935,6 @@ "@types/prop-types" "*" csstype "^3.0.2" -"@types/react@^17.0.40": - version "17.0.53" - resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.53.tgz#10d4d5999b8af3d6bc6a9369d7eb953da82442ab" - integrity sha512-1yIpQR2zdYu1Z/dc1OxC+MA6GR240u3gcnP4l6mvj/PJiVaqHsQPmWttsvHsfnhfPbU2FuGmo0wSITPygjBmsw== - dependencies: - "@types/prop-types" "*" - "@types/scheduler" "*" - csstype "^3.0.2" - "@types/reactcss@*": version "1.2.6" resolved "https://registry.yarnpkg.com/@types/reactcss/-/reactcss-1.2.6.tgz#133c1e7e896f2726370d1d5a26bf06a30a038bcc" @@ -1951,11 +1942,6 @@ dependencies: "@types/react" "*" -"@types/scheduler@*": - version "0.16.2" - resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39" - integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew== - "@types/stack-utils@^2.0.0": version "2.0.1" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c" From 9d83ca2cc62e19a199d5f8f7b8e2a2619f985d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Tom=C3=A1=C5=A1ko?= Date: Fri, 9 Jun 2023 09:03:52 +0200 Subject: [PATCH 2/3] FIXED: Editing state and focus when hoolding Enter key or scrolling due to the end of a table being reached. (#1637) --- .../src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts | 2 +- .../src/model/entities/TablePanelView/TablePanelView.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend-html/src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts b/frontend-html/src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts index ab0c9e3648..e6ab4becf3 100644 --- a/frontend-html/src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts +++ b/frontend-html/src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts @@ -97,7 +97,7 @@ export function onFieldKeyDown(ctx: any) { }); tablePanelView.setEditing(true); - tablePanelView.triggerOnFocusTable(); + //tablePanelView.triggerOnFocusTable(); tablePanelView.scrollToCurrentCell(); break; } diff --git a/frontend-html/src/model/entities/TablePanelView/TablePanelView.tsx b/frontend-html/src/model/entities/TablePanelView/TablePanelView.tsx index c81211ef5f..118799591e 100644 --- a/frontend-html/src/model/entities/TablePanelView/TablePanelView.tsx +++ b/frontend-html/src/model/entities/TablePanelView/TablePanelView.tsx @@ -276,7 +276,7 @@ export class TablePanelView implements ITablePanelView { const _this = this; flow(function*() { if (_this.isEditing) { - _this.setEditing(false); + //_this.setEditing(false); yield*flushCurrentRowData(_this)(); } })(); From 004f57f69fc17a94bbf17f377acb397d01337392 Mon Sep 17 00:00:00 2001 From: Jindrich Susen Date: Fri, 9 Jun 2023 10:34:22 +0200 Subject: [PATCH 3/3] Commented code removed --- .../src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts | 1 - .../src/model/entities/TablePanelView/TablePanelView.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/frontend-html/src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts b/frontend-html/src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts index e6ab4becf3..9c8f0d5efc 100644 --- a/frontend-html/src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts +++ b/frontend-html/src/model/actions-ui/DataView/TableView/onFieldKeyDown.ts @@ -97,7 +97,6 @@ export function onFieldKeyDown(ctx: any) { }); tablePanelView.setEditing(true); - //tablePanelView.triggerOnFocusTable(); tablePanelView.scrollToCurrentCell(); break; } diff --git a/frontend-html/src/model/entities/TablePanelView/TablePanelView.tsx b/frontend-html/src/model/entities/TablePanelView/TablePanelView.tsx index 118799591e..f18c548fb7 100644 --- a/frontend-html/src/model/entities/TablePanelView/TablePanelView.tsx +++ b/frontend-html/src/model/entities/TablePanelView/TablePanelView.tsx @@ -276,7 +276,6 @@ export class TablePanelView implements ITablePanelView { const _this = this; flow(function*() { if (_this.isEditing) { - //_this.setEditing(false); yield*flushCurrentRowData(_this)(); } })();