Skip to content

Commit 5ebd071

Browse files
authored
[NoteButton] Use multiline text field for wordwrap (#4157)
1 parent e63520e commit 5ebd071

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/components/Buttons/NoteButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export default function NoteButton(props: NoteButtonProps): ReactElement {
6464
buttonIdCancel="note-edit-cancel"
6565
buttonIdClear="note-edit-clear"
6666
buttonIdConfirm="note-edit-confirm"
67+
multiline
6768
textFieldId="note-text-field"
6869
/>
6970
</>

src/components/Dialogs/EditTextDialog.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface EditTextDialogProps {
3131
buttonIdConfirm?: string;
3232
buttonTextIdCancel?: string;
3333
buttonTextIdConfirm?: string;
34+
multiline?: boolean;
3435
textFieldId?: string;
3536
}
3637

@@ -70,6 +71,10 @@ export default function EditTextDialog(
7071

7172
function confirmIfEnter(event: KeyboardEvent<any>): void {
7273
if (event.key === Key.Enter) {
74+
// Prevent newline in note. If we want to enable newlines (when multiline
75+
// is true), we'll need to manage Enter vs (e.g.) Shift+Enter and which
76+
// one confirms vs adds a newline.
77+
event.preventDefault();
7378
onConfirm();
7479
}
7580
}
@@ -101,28 +106,27 @@ export default function EditTextDialog(
101106
variant="standard"
102107
autoFocus
103108
value={text}
109+
multiline={props.multiline}
104110
onChange={(event) => setText(event.target.value)}
105-
onKeyPress={confirmIfEnter}
111+
onKeyDown={confirmIfEnter}
106112
slotProps={{ input: { endAdornment } }}
107113
id={props.textFieldId}
108114
/>
109115
</DialogContent>
110116
<DialogActions>
111117
<Button
112-
onClick={onCancel}
113-
variant="outlined"
114-
color="primary"
115118
data-testid={props.buttonIdCancel}
116119
id={props.buttonIdCancel}
120+
onClick={onCancel}
121+
variant="outlined"
117122
>
118123
{t(props.buttonTextIdCancel ?? "buttons.cancel")}
119124
</Button>
120125
<Button
121-
onClick={onConfirm}
122-
variant="outlined"
123-
color="primary"
124126
data-testid={props.buttonIdConfirm}
125127
id={props.buttonIdConfirm}
128+
onClick={onConfirm}
129+
variant="contained"
126130
>
127131
{t(props.buttonTextIdConfirm ?? "buttons.confirm")}
128132
</Button>

0 commit comments

Comments
 (0)