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: Save keyboard shortcut didn't persist focused field contents #1730

Merged
merged 1 commit into from
Jul 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
9 changes: 1 addition & 8 deletions frontend-html/src/gui/connections/CScreenToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,7 @@ import { About } from "model/entities/AboutInfo";
import { showDialog } from "model/selectors/getDialogStack";
import { AboutDialog } from "gui/Components/Dialogs/AboutDialog";
import { geScreenActionButtonsState } from "model/actions-ui/ScreenToolbar/saveBottonVisible";

function isSaveShortcut(event: any) {
return event.key === "s" && (event.ctrlKey || event.metaKey);
}

function isRefreshShortcut(event: any) {
return event.key === "r" && (event.ctrlKey || event.metaKey);
}
import { isRefreshShortcut, isSaveShortcut } from "utils/keyShortcuts";

@observer
export class CScreenToolbar extends React.Component<{}> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { handleError } from "model/actions/handleError";
import { getDataView } from "model/selectors/DataView/getDataView";
import { shouldProceedToChangeRow } from "model/actions-ui/DataView/TableView/shouldProceedToChangeRow";
import { getGridFocusManager } from "model/entities/GridFocusManager";
import { isSaveShortcut } from "utils/keyShortcuts";

export function onFieldKeyDown(ctx: any) {

Expand All @@ -40,6 +41,11 @@ export function onFieldKeyDown(ctx: any) {
try {
const dataView = getDataView(ctx);
const tablePanelView = getTablePanelView(ctx);
if( isSaveShortcut(event)){
tablePanelView.setEditing(false);
yield*flushCurrentRowData(ctx)();
return;
}
switch (event.key) {
case "Tab": {
if (isGoingToChangeRow(event)) {
Expand Down
26 changes: 26 additions & 0 deletions frontend-html/src/utils/keyShortcuts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright 2005 - 2023 Advantage Solutions, s. r. o.

This file is part of ORIGAM (http://www.origam.org).

ORIGAM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

ORIGAM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with ORIGAM. If not, see <http://www.gnu.org/licenses/>.
*/

export function isSaveShortcut(event: any) {
return event.key === "s" && (event.ctrlKey || event.metaKey);
}

export function isRefreshShortcut(event: any) {
return event.key === "r" && (event.ctrlKey || event.metaKey);
}