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: Focus moved to filter after editing a field in grid 2023.1 #2100

Merged
merged 4 commits into from Oct 24, 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 @@ -405,7 +405,7 @@ export class RawTable extends React.Component<ITableProps & { isVisible: boolean
onFocus(event: any){
if(event.target){
let dataView = getDataView(this.context.tablePanelView);
dataView.formFocusManager.setLastFocused(event.target! as IFocusable);
dataView.gridFocusManager.setLastFocusedFilter(event.target! as IFocusable);
}
}

Expand Down
Expand Up @@ -29,7 +29,6 @@ interface IClearableInputData{
value?: string;
onChange?: (event: any) => void;
onBlur?: (event: any) => void;
autofocus?: boolean;
}

export const ClearableInput = React.forwardRef<HTMLInputElement, IClearableInputData>((props, ref) => {
Expand Down
14 changes: 12 additions & 2 deletions frontend-html/src/model/entities/FormFocusManager.ts
Expand Up @@ -20,10 +20,16 @@ along with ORIGAM. If not, see <http://www.gnu.org/licenses/>.
import { isGlobalAutoFocusDisabled } from "model/actions-ui/ScreenToolbar/openSearchWindow";
import { compareTabIndexOwners, ITabIndexOwner, TabIndex } from "model/entities/TabIndexOwner";
import { requestFocus } from "utils/focus";
import { getDataView } from "model/selectors/DataView/getDataView";

export class FormFocusManager {
autoFocusDisabled = false;

private isFormPerspectiveActive(){
const dataView = getDataView(this.parent);
return dataView.isFormViewActive();
}

stopAutoFocus() {
this.autoFocusDisabled = true;
}
Expand Down Expand Up @@ -65,11 +71,15 @@ export class FormFocusManager {
return;
}
this.lastFocused = focusable;
requestFocus(focusable as any);
if (this.isFormPerspectiveActive()) {
requestFocus(focusable as any);
}
}

refocusLast() {
requestFocus(this.lastFocused as any);
if (this.isFormPerspectiveActive()) {
requestFocus(this.lastFocused as any);
}
}

forceAutoFocus() {
Expand Down
Expand Up @@ -403,8 +403,8 @@ export class FormScreenLifecycle02 implements IFormScreenLifecycle02 {
const rootDataView = rootDataViews[0];
const filtersDisplayed = getTablePanelView(rootDataView)!.filterConfiguration
.isFilterControlsDisplayed
if(workFinished && !filtersDisplayed && rootDataView.isTableViewActive()){
rootDataView.formFocusManager.refocusLast();
if(workFinished && !filtersDisplayed){
rootDataView.gridFocusManager.refocusLastFilter();
}
}
),
Expand Down
20 changes: 19 additions & 1 deletion frontend-html/src/model/entities/GridFocusManager.ts
Expand Up @@ -7,6 +7,7 @@ import { IDataView } from "model/entities/types/IDataView";

export class GridFocusManager {
private _activeEditor: IFocusable | undefined;
private _lastFocusedFilter: IFocusable | undefined;
public focusTableOnReload: boolean = true;
private readonly _dataViewModelInstanceId: string;
get canFocusTable(){
Expand Down Expand Up @@ -49,7 +50,24 @@ export class GridFocusManager {
}
}
focusEditor() {
requestFocus(this._activeEditor as any);
if (this.isTablePerspectiveActive()) {
requestFocus(this._activeEditor as any);
}
}

setLastFocusedFilter(focusable: IFocusable) {
this._lastFocusedFilter = focusable;
}

refocusLastFilter() {
if (this.isTablePerspectiveActive()) {
requestFocus(this._lastFocusedFilter as any);
}
}

private isTablePerspectiveActive(){
const dataView = getDataView(this.parent);
return dataView.isTableViewActive();
}
}

Expand Down