Skip to content

Commit 03e8629

Browse files
julsqlclaude
andcommitted
fix(Drawing/Measures): make drawing work in Safari
In Safari, clicking on the map did not add any point to the sketch and double-clicking selected the tooltip text instead of finishing the drawing. Three cumulative causes: - `ol/ol.css` (which sets `user-select: none` on `.ol-viewport`) is not guaranteed to be loaded by the host application. Without it, `mousedown` on the map starts a text selection; Safari then fires `pointercancel` and `ol/interaction/Draw` never receives its `pointerup`, so no point is added. - `ol/Overlay` defaults to `class="ol-overlay-container ol-selectable"`, which explicitly re-enables text selection on the drawing and measure tooltips. - The `Drawing` tooltip overlays were created without `stopEvent: false` (unlike the `Measures` ones), so they landed in `ol-overlaycontainer-stopevent` and blocked event propagation to the map. Fixes: - Drawing: add `stopEvent: false` and an explicit `className` without `ol-selectable` on both tooltip overlays (line and polygon). - Measures: add the same explicit `className` on `measureTooltip` and `helpTooltip`. - GPFgeneralWidget.css: fall back to `user-select: none` and `-webkit-touch-callout: none` on `.ol-viewport` / `.ol-unselectable`, while restoring `user-select: text` on `.ol-selectable`, widget inputs/textareas and `[contenteditable]` elements. - GPFdrawing.css / GPFmeasureToolTip.css: `user-select: none` and `pointer-events: none` on the tooltips. Closes #573 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01832PBwBgcAdTDV2ZrhigKQ
1 parent e53673d commit 03e8629

6 files changed

Lines changed: 52 additions & 0 deletions

File tree

DRAFT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ __DATE__
2525

2626
* 🐛 [Fixed]
2727

28+
- Drawing / Measures : sur Safari, le clic ne permettait pas de tracer et le double-clic sélectionnait le texte de l'infobulle ("Double-cliquer pour terminer", mesures) au lieu de terminer la saisie
29+
2830
* 🔒 [Security]
2931

3032
---

src/packages/CSS/Controls/Drawing/GPFdrawing.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ div[id^=GPdrawingBasicPanel-] {
5555

5656
.gpf-draw-linestring-tooltip {
5757
transform: translate(calc(100% + 35px), -14px);
58+
-moz-user-select: none;
59+
-khtml-user-select: none;
60+
-webkit-user-select: none;
61+
user-select: none;
62+
pointer-events: none;
5863
}
5964

6065
.gpf-draw-linestring-tooltip::before {

src/packages/CSS/Controls/Measures/GPFmeasureToolTip.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
color: white;
88
padding: 4px 8px;
99
white-space: nowrap;
10+
-moz-user-select: none;
11+
-khtml-user-select: none;
12+
-webkit-user-select: none;
13+
user-select: none;
14+
pointer-events: none;
1015
}
1116

1217
.GPmeasureTooltip-measure {

src/packages/CSS/GPFgeneralWidget.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,3 +587,37 @@ input[type="checkbox"]:checked + .GPshowMoreOptions {
587587
.gpf-panel__body {
588588
overflow: auto;
589589
}
590+
591+
/*******************************/
592+
/* selection de texte / carte */
593+
/*******************************/
594+
/*
595+
* Filet de sécurité si la feuille de style d'OpenLayers (ol/ol.css) n'est pas
596+
* chargée par l'application hôte : sans `user-select: none` sur le viewport,
597+
* un clic sur la carte démarre une sélection de texte. Safari émet alors un
598+
* `pointercancel` et l'interaction de dessin ne reçoit jamais le `pointerup`
599+
* (le tracé ne se fait pas), et le double-clic sélectionne le texte au lieu de
600+
* terminer la saisie.
601+
*/
602+
.ol-viewport,
603+
.ol-unselectable {
604+
-webkit-touch-callout: none;
605+
-webkit-user-select: none;
606+
-moz-user-select: none;
607+
-ms-user-select: none;
608+
user-select: none;
609+
}
610+
611+
/* on rétablit la sélection là où l'utilisateur saisit du texte */
612+
.ol-selectable,
613+
.GPwidget input,
614+
.GPwidget textarea,
615+
.gpf-widget input,
616+
.gpf-widget textarea,
617+
[contenteditable="true"] {
618+
-webkit-touch-callout: default;
619+
-webkit-user-select: text;
620+
-moz-user-select: text;
621+
-ms-user-select: text;
622+
user-select: text;
623+
}

src/packages/Controls/Drawing/Drawing.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,8 @@ class Drawing extends Control {
18271827
context.tootlTipElem.innerText = "Double-cliquer pour terminer";
18281828
context.tooltipOvl = new Overlay({
18291829
element : context.tootlTipElem,
1830+
stopEvent : false,
1831+
className : "ol-overlay-container",
18301832
positioning : "top-right"
18311833
});
18321834

@@ -1877,6 +1879,8 @@ class Drawing extends Control {
18771879
context.tootlTipElem.innerText = "Double-cliquer pour terminer";
18781880
context.tooltipOvl = new Overlay({
18791881
element : context.tootlTipElem,
1882+
stopEvent : false,
1883+
className : "ol-overlay-container",
18801884
positioning : "top-right"
18811885
});
18821886
context.interactionCurrent.on("drawend", function (deEv) {

src/packages/Controls/Measures/Measures.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ var Measures = {
350350
this.measureTooltip = new Overlay({
351351
element : this.measureTooltipElement,
352352
stopEvent : false,
353+
className : "ol-overlay-container",
353354
offset : [0, -15],
354355
positioning : "bottom-center"
355356
});
@@ -374,6 +375,7 @@ var Measures = {
374375
this.helpTooltip = new Overlay({
375376
element : this.helpTooltipElement,
376377
stopEvent : false,
378+
className : "ol-overlay-container",
377379
offset : [15, 0],
378380
positioning : "center-left"
379381
});

0 commit comments

Comments
 (0)