Skip to content

Commit 5145b41

Browse files
committed
Use native disclosure triangle in context menu if supported
1 parent 14375f2 commit 5145b41

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/mapml.css

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
background-color: #fff;
256256
cursor: default;
257257
position: absolute;
258-
width: 150px;
258+
width: 160px;
259259
z-index: 10001;
260260
}
261261

@@ -297,6 +297,24 @@
297297
}
298298
}
299299

300+
.mapml-contextmenu-item[aria-controls] span::after {
301+
content:">";
302+
}
303+
@supports (list-style-type: disclosure-open) {
304+
.mapml-contextmenu-item[aria-controls] span {
305+
display: inline-block;
306+
}
307+
.mapml-contextmenu-item[aria-controls] span::after {
308+
content:"";
309+
display: list-item;
310+
list-style-type: disclosure-open;
311+
margin-inline-start: 20px;
312+
}
313+
.mapml-contextmenu-item[aria-expanded="false"] span::after {
314+
list-style-type: disclosure-closed;
315+
}
316+
}
317+
300318
/*
301319
* Debug mode.
302320
*/

src/mapml/handlers/ContextMenu.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export var ContextMenu = L.Handler.extend({
3434
callback:this._toggleControls,
3535
},
3636
{
37-
text:"Copy Coordinates (<kbd>C</kbd>) <span aria-hidden='true'>></span>",
37+
text:"Copy Coordinates (<kbd>C</kbd>)<span></span>",
3838
callback:this._copyCoords,
3939
hideOnSelect:false,
4040
popup:true,
@@ -522,7 +522,7 @@ export var ContextMenu = L.Handler.extend({
522522

523523
if(key === 13)
524524
e.preventDefault();
525-
if(key !== 16 && key!== 9 && !(!this._layerClicked && key === 67) && path[0].innerText !== "Copy Coordinates (C) >")
525+
if(key !== 16 && key!== 9 && !(!this._layerClicked && key === 67) && path[0].innerText !== "Copy Coordinates (C)")
526526
this._hide();
527527
switch(key){
528528
case 13: //ENTER KEY
@@ -579,15 +579,15 @@ export var ContextMenu = L.Handler.extend({
579579
copyEl.setAttribute("aria-expanded","true");
580580
menu.style.display = "block";
581581

582-
if (click.containerPoint.x + 150 + 80 > mapSize.x) {
582+
if (click.containerPoint.x + 160 + 80 > mapSize.x) {
583583
menu.style.left = 'auto';
584-
menu.style.right = 150 + 'px';
584+
menu.style.right = 160 + 'px';
585585
} else {
586-
menu.style.left = 150 + 'px';
586+
menu.style.left = 160 + 'px';
587587
menu.style.right = 'auto';
588588
}
589589

590-
if (click.containerPoint.y + 150 > mapSize.y) {
590+
if (click.containerPoint.y + 160 > mapSize.y) {
591591
menu.style.top = 'auto';
592592
menu.style.bottom = 20 + 'px';
593593
} else {
@@ -599,15 +599,15 @@ export var ContextMenu = L.Handler.extend({
599599

600600
_hideCoordMenu: function(e){
601601
if(e.srcElement.parentElement.classList.contains("mapml-submenu") ||
602-
e.srcElement.innerText === "Copy Coordinates (C) >")return;
602+
e.srcElement.innerText === "Copy Coordinates (C)")return;
603603
let menu = this._coordMenu, copyEl = this._items[5].el.el;
604604
copyEl.setAttribute("aria-expanded","false");
605605
menu.style.display = "none";
606606
},
607607

608608
_onItemMouseOver: function (e) {
609609
L.DomUtil.addClass(e.target || e.srcElement, 'over');
610-
if(e.srcElement.innerText === "Copy Coordinates (C) >") this._showCoordMenu(e);
610+
if(e.srcElement.innerText === "Copy Coordinates (C)") this._showCoordMenu(e);
611611
},
612612

613613
_onItemMouseOut: function (e) {

0 commit comments

Comments
 (0)