Skip to content

Commit df5e7b1

Browse files
Copilotpattonwebz
andcommitted
fix: address review feedback on RichTextarea keyboard and pressed state handling
Co-authored-by: pattonwebz <3902039+pattonwebz@users.noreply.github.com>
1 parent f4fcfde commit df5e7b1

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/issueModal/components/RichTextarea.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ export const RichTextarea = ( { value, onChange, label, help, rows = 3, disabled
7474
editorRef.current?.contains( document.activeElement )
7575
) {
7676
saveSelection();
77+
setIsBold( document.queryCommandState( 'bold' ) );
78+
setIsItalic( document.queryCommandState( 'italic' ) );
79+
setIsUnderline( document.queryCommandState( 'underline' ) );
7780
}
7881
};
7982
document.addEventListener( 'selectionchange', onSelectionChange );
@@ -90,8 +93,9 @@ export const RichTextarea = ( { value, onChange, label, help, rows = 3, disabled
9093
return;
9194
}
9295
const onKeyDownCapture = ( e ) => {
93-
if ( ( e.ctrlKey || e.metaKey ) && ( FORMATTING_SHORTCUTS[ e.key ] || e.key === 'k' ) ) {
94-
e.stopImmediatePropagation();
96+
const key = e.key.toLowerCase();
97+
if ( ( e.ctrlKey || e.metaKey ) && ( FORMATTING_SHORTCUTS[ key ] || key === 'k' ) ) {
98+
e.preventDefault();
9599
}
96100
};
97101
editor.addEventListener( 'keydown', onKeyDownCapture, true );
@@ -256,15 +260,16 @@ if ( ( e.ctrlKey || e.metaKey ) && ( FORMATTING_SHORTCUTS[ e.key ] || e.key ===
256260
return;
257261
}
258262

259-
const command = FORMATTING_SHORTCUTS[ e.key ];
263+
const key = e.key.toLowerCase();
264+
const command = FORMATTING_SHORTCUTS[ key ];
260265
if ( command ) {
261266
e.preventDefault();
262267
e.stopPropagation();
263268
applyFormatting( command );
264269
return;
265270
}
266271

267-
if ( e.key === 'k' ) {
272+
if ( key === 'k' ) {
268273
e.preventDefault();
269274
e.stopPropagation();
270275
saveSelection();

0 commit comments

Comments
 (0)