Skip to content

Commit 69de40f

Browse files
Copilotalexr00
andcommitted
Add aria-label and refactor event handler for better code quality
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 2ac1bf2 commit 69de40f

File tree

1 file changed

+8
-2
lines changed
  • webviews/createPullRequestViewNew

1 file changed

+8
-2
lines changed

webviews/createPullRequestViewNew/app.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,19 @@ export function main() {
173173
}
174174

175175
function openDescriptionSettings(event: React.MouseEvent | React.KeyboardEvent): void {
176+
let shouldExecute = false;
177+
176178
if (event.type === 'keydown') {
177179
const keyEvent = event as React.KeyboardEvent;
178180
if (keyEvent.key === 'Enter' || keyEvent.key === ' ') {
179181
event.preventDefault();
180-
ctx.postMessage({ command: 'pr.openDescriptionSettings' });
182+
shouldExecute = true;
181183
}
182184
} else if (event.type === 'click') {
185+
shouldExecute = true;
186+
}
187+
188+
if (shouldExecute) {
183189
ctx.postMessage({ command: 'pr.openDescriptionSettings' });
184190
}
185191
}
@@ -339,7 +345,7 @@ export function main() {
339345

340346
<div className='group-description-header'>
341347
<label htmlFor='description' className='input-title'>Description</label>
342-
<button type='button' title='Open pull request description settings' className='description-settings-action icon-button' onClick={openDescriptionSettings} onKeyDown={openDescriptionSettings} tabIndex={0}>{settingsIcon}</button>
348+
<button type='button' title='Open pull request description settings' aria-label='Open pull request description settings' className='description-settings-action icon-button' onClick={openDescriptionSettings} onKeyDown={openDescriptionSettings} tabIndex={0}>{settingsIcon}</button>
343349
</div>
344350
<div className='group-description'>
345351
<textarea

0 commit comments

Comments
 (0)