Skip to content

Commit e208bba

Browse files
committed
refactor: limit ctrl+enter action only at when creating reation on relation map
1 parent 1e1ce02 commit e208bba

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

apps/client/src/widgets/dialogs/prompt.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface PromptDialogOptions {
2424
shown?: PromptShownDialogCallback;
2525
callback?: (value: string | null) => void;
2626
readOnly?: boolean;
27+
submitWithCtrlEnter?: boolean;
2728
}
2829

2930
export default function PromptDialog() {
@@ -69,7 +70,7 @@ export default function PromptDialog() {
6970
submitValue.current = null;
7071
opts.current = undefined;
7172
}}
72-
footer={<Button text={t("prompt.ok")} keyboardShortcut="ctrl+return" kind="primary" />}
73+
footer={<Button text={t("prompt.ok")} keyboardShortcut={opts.current?.submitWithCtrlEnter ? "ctrl+return" : "Enter"} kind="primary" />}
7374
show={shown}
7475
stackable
7576
>
@@ -79,7 +80,7 @@ export default function PromptDialog() {
7980
currentValue={value} onChange={setValue}
8081
readOnly={opts.current?.readOnly}
8182
onKeyDown={(e: KeyboardEvent) => {
82-
if ((e.ctrlKey || e.metaKey) && e.key === "Enter") {
83+
if (opts.current?.submitWithCtrlEnter && (e.ctrlKey || e.metaKey) && e.key === "Enter") {
8384
e.preventDefault();
8485
submitValue.current = answerRef.current?.value || value;
8586
setShown(false);

apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ function useRelationCreation({ mapApiRef, jsPlumbApiRef }: { mapApiRef: RefObjec
416416
if (!originalEvent || !mapApiRef.current) return;
417417

418418
const name = await dialog.prompt({
419+
submitWithCtrlEnter: true,
419420
message: t("relation_map.specify_new_relation_name"),
420421
shown: ({ $answer }) => {
421422
if (!$answer) {

0 commit comments

Comments
 (0)