Skip to content

Commit 642cf20

Browse files
committed
A11y: Replace non-semantic div buttons with <button> in URLPopUpSection
- Replaced div role='button' elements with proper button elements - Removed redundant ARIA roles (button role is implicit in button elements) - Fixed aria-label on edit button (was using copyLinkText instead of editLinkText) - Set alt='' on images since buttons already have aria-labels (avoiding redundancy) - Added CSS reset for button elements to maintain consistent styling - Improved keyboard accessibility and screen reader support Issue: #12017 Signed-off-by: omkar hole <[email protected]> Change-Id: I06f6da85ffbaa656962fad3207c6a4c132d07572
1 parent a68f774 commit 642cf20

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

browser/css/cool.css

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,11 +1193,25 @@ body {
11931193
}
11941194

11951195
.hyperlink-popup-btn {
1196-
display: inline-block;
1197-
margin-left: 12px;
1196+
display: inline-flex;
1197+
align-items: center;
1198+
justify-content: center;
11981199
vertical-align: middle;
1200+
margin-left: 12px;
11991201
width: 26px;
12001202
height: 26px;
1203+
/* Reset default native button styles */
1204+
-webkit-appearance: none;
1205+
-moz-appearance: none;
1206+
appearance: none;
1207+
background: none;
1208+
border: none;
1209+
padding: 0;
1210+
box-shadow: none;
1211+
cursor: pointer;
1212+
font: inherit;
1213+
color: inherit;
1214+
outline: none;
12011215
}
12021216

12031217
.hyperlink-popup-btn:hover {

browser/src/canvas/sections/URLPopUpSection.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,46 +65,43 @@ class URLPopUpSection extends HTMLObjectSection {
6565
const link = window.L.DomUtil.createWithId('a', this.linkId, parent);
6666
link.innerText = url;
6767
const copyLinkText = _('Copy link location');
68-
const copyBtn = window.L.DomUtil.createWithId('div', this.copyButtonId, parent);
68+
const copyBtn = window.L.DomUtil.createWithId('button', this.copyButtonId, parent);
6969
window.L.DomUtil.addClass(copyBtn, 'hyperlink-popup-btn');
7070
copyBtn.setAttribute('title', copyLinkText);
71-
copyBtn.setAttribute('role', 'button');
7271
copyBtn.setAttribute('aria-label', copyLinkText);
7372

7473
const imgCopyBtn = window.L.DomUtil.create('img', 'hyperlink-pop-up-copyimg', copyBtn);
7574
app.LOUtil.setImage(imgCopyBtn, 'lc_copyhyperlinklocation.svg', app.map);
7675
imgCopyBtn.setAttribute('width', 18);
7776
imgCopyBtn.setAttribute('height', 18);
78-
imgCopyBtn.setAttribute('alt', copyLinkText);
77+
imgCopyBtn.setAttribute('alt', '');
7978
imgCopyBtn.style.padding = '4px';
8079

8180
const editLinkText = _('Edit link');
82-
const editBtn = window.L.DomUtil.createWithId('div', this.editButtonId, parent);
81+
const editBtn = window.L.DomUtil.createWithId('button', this.editButtonId, parent);
8382
window.L.DomUtil.addClass(editBtn, 'hyperlink-popup-btn');
8483
editBtn.setAttribute('title', editLinkText);
85-
editBtn.setAttribute('role', 'button');
86-
editBtn.setAttribute('aria-label', copyLinkText);
84+
editBtn.setAttribute('aria-label', editLinkText);
8785

8886

8987
const imgEditBtn = window.L.DomUtil.create('img', 'hyperlink-pop-up-editimg', editBtn);
9088
app.LOUtil.setImage(imgEditBtn, 'lc_edithyperlink.svg', app.map);
9189
imgEditBtn.setAttribute('width', 18);
9290
imgEditBtn.setAttribute('height', 18);
93-
imgEditBtn.setAttribute('alt', editLinkText);
91+
imgEditBtn.setAttribute('alt', '');
9492
imgEditBtn.style.padding = '4px';
9593

9694
const removeLinkText = _('Remove link');
97-
const removeBtn = window.L.DomUtil.createWithId('div', this.removeButtonId, parent);
95+
const removeBtn = window.L.DomUtil.createWithId('button', this.removeButtonId, parent);
9896
window.L.DomUtil.addClass(removeBtn, 'hyperlink-popup-btn');
9997
removeBtn.setAttribute('title', removeLinkText);
100-
removeBtn.setAttribute('role', 'button');
10198
removeBtn.setAttribute('aria-label', removeLinkText);
10299

103100
const imgRemoveBtn = window.L.DomUtil.create('img', 'hyperlink-pop-up-removeimg', removeBtn);
104101
app.LOUtil.setImage(imgRemoveBtn, 'lc_removehyperlink.svg', app.map);
105102
imgRemoveBtn.setAttribute('width', 18);
106103
imgRemoveBtn.setAttribute('height', 18);
107-
imgRemoveBtn.setAttribute('alt', removeLinkText);
104+
imgRemoveBtn.setAttribute('alt', '');
108105
imgRemoveBtn.style.padding = '4px';
109106

110107
this.arrowDiv = document.createElement('div');

0 commit comments

Comments
 (0)