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: Enter in grid did not always move focus to the next row #1642

Merged
merged 3 commits into from Jun 13, 2023
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 @@ -48,7 +48,7 @@ export class NumberEditor extends React.Component<{
subscribeToFocusManager?: (obj: IFocusable, onBlur: ()=> Promise<void>) => 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<HTMLInputElement>();
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -107,7 +108,12 @@ export class TableViewInner extends React.Component<ITableViewProps & { dataView
refTable = (elmTable: RawTable | null) => {
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
);
Expand Down
Expand Up @@ -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);
Expand Down Expand Up @@ -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":
Expand Down
Expand Up @@ -97,7 +97,6 @@ export function onFieldKeyDown(ctx: any) {
});

tablePanelView.setEditing(true);
tablePanelView.triggerOnFocusTable();
tablePanelView.scrollToCurrentCell();
break;
}
Expand Down
Expand Up @@ -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();
Expand Down Expand Up @@ -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--;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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}
)
Expand Down
3 changes: 3 additions & 0 deletions frontend-html/src/model/entities/GridFocusManager.ts
Expand Up @@ -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) {
}
Expand Down
Expand Up @@ -276,7 +276,6 @@ export class TablePanelView implements ITablePanelView {
const _this = this;
flow(function*() {
if (_this.isEditing) {
_this.setEditing(false);
yield*flushCurrentRowData(_this)();
}
})();
Expand Down
14 changes: 0 additions & 14 deletions frontend-html/yarn.lock
Expand Up @@ -1935,27 +1935,13 @@
"@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"
integrity sha512-qaIzpCuXNWomGR1Xq8SCFTtF4v8V27Y6f+b9+bzHiv087MylI/nTCqqdChNeWS7tslgROmYB7yeiruWX7WnqNg==
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"
Expand Down