Skip to content

Commit f2efa61

Browse files
committed
feat(GetFeatureInfo): améliore l’ouverture des accordéons
1 parent 510e9cd commit f2efa61

5 files changed

Lines changed: 29 additions & 20 deletions

File tree

DRAFT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ __DATE__
2020
- Tooltips : les tooltips au survol des boutons ne peuvent pas être survolées (#571)
2121
- LayerImport : le bouton retour est inclut dans le panel header (#575)
2222
- GFI : activation du GFI au clic gauche et selon panels incompatibles (#1167)
23+
- GFI : suppression des animations à l’ouverture des accordéons (#580)
2324
- ContextMenu : modification des paramètres par défaut (#1167)
2425
- SearchBar : option selectGeometry : permet de sélectionner uniquement l'extent plutot que le point si existant (besoin extraction)
2526
- LayerImport : alternative UI pour importer avec un drag and drop de fichier (#576)
@@ -31,6 +32,7 @@ __DATE__
3132
* 🐛 [Fixed]
3233

3334
- LayerImport : fixe la hauteur du contenu dans certains cas (#575)
35+
- GFI : empêche que l’ouverture de l’accordéon déplace le site en entier (#580)
3436

3537
* 🔒 [Security]
3638

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "geopf-extensions-openlayers",
33
"description": "French Geoportal Extensions for OpenLayers libraries",
4-
"version": "1.0.0-beta.13-575",
5-
"date": "26/08/2026",
4+
"version": "1.0.0-beta.13-580",
5+
"date": "31/08/2026",
66
"module": "src/index.js",
77
"main": "src/index.js",
88
"types": "src/index.d.ts",

src/packages/CSS/Controls/GetFeatureInfo/GPFgetFeatureInfo.css

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ div[id^=GPgetFeatureInfo-] {
55

66
div[id^=GPgetFeatureInfoAccordionGroup-] {
77
user-select: text;
8-
max-height: 300px;
98
}
109

1110
/* Showing/hiding */
1211

1312
dialog:has(button.GPcloseGetFeatureInfo[aria-pressed="true"]) {
14-
display: block;
13+
display: flex;
1514
visibility: visible;
1615
opacity: 100%;
1716
width: 350px;
@@ -32,14 +31,17 @@ dialog[id^="GPgetFeatureInfoPanel-"] {
3231
overflow-x: hidden;
3332
}
3433

35-
.GPgetFeatureInfoAccordionGroup {
36-
overflow-y: auto;
37-
scrollbar-width: thin;
38-
}
3934

4035
.GPgetFeatureInfoAccordionContent {
41-
overflow-x: scroll;
36+
overflow-x: auto;
4237
scrollbar-width: thin;
38+
padding-inline: 1rem;
39+
/* désactive l'animation du fr-collapse car on ne connait pas la hauteur du contenu */
40+
transition: none !important;
41+
}
42+
43+
.GPgetFeatureInfoAccordionContent::before {
44+
transition: none !important;
4345
}
4446

4547
.waiting-div-container {

src/packages/Controls/GetFeatureInfo/GetFeatureInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ class GetFeatureInfo extends Control {
510510
var layername = this.getLayerTitle(gfiLayer);
511511

512512
var content = null;
513-
var accordeon = this._createGetFeatureInfoLayerAccordion(layername);
513+
var accordeon = this._createGetFeatureInfoLayerAccordion(layername, this.getFeatureInfoPanelDiv);
514514
// on affiche pas l'entrée avant d'être confirmation qu'elle aura du contenu renvoyé
515515
accordeon.style.display = "none";
516516
var pending = true;

src/packages/Controls/GetFeatureInfo/GetFeatureInfoDOM.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ var GetFeatureInfoDOM = {
169169
* Create accordeon
170170
* see evenement !
171171
* @param { String } layername nom du layer
172-
* @param { String } content contenu du gfi
172+
* @param { HTMLElement } scrollableContainer conteneur scrollable de l'accordeon
173173
* @returns {HTMLElement} DOM element
174174
*/
175-
_createGetFeatureInfoLayerAccordion : function (layername) {
175+
_createGetFeatureInfoLayerAccordion : function (layername, scrollableContainer) {
176176
var dsfrTemplate = this.stringToHTML(`
177177
<section class="fr-accordion">
178178
<h3 class="fr-accordion__title">
@@ -194,14 +194,19 @@ var GetFeatureInfoDOM = {
194194
if (e.currentTarget.ariaExpanded === "true") {
195195
collapse.classList.add("fr-collapse--expanded");
196196
collapse.classList.remove("GPelementHidden");
197-
// on centre la vue dans le dialog sur le bouton cliqué
198-
requestAnimationFrame(() => {
199-
button.scrollIntoView({
200-
behavior : "smooth",
201-
block : "start",
202-
inline : "nearest"
203-
});
204-
});
197+
// on déplace la section dans le panel
198+
setTimeout(() => {
199+
const elementRect = button.parentNode.parentNode.getBoundingClientRect();
200+
const containerRect = scrollableContainer.getBoundingClientRect();
201+
202+
// si le bas n'est pas visible, on aligne le haut de la section
203+
if (elementRect.bottom > containerRect.bottom) {
204+
scrollableContainer.scrollTo({
205+
top : scrollableContainer.scrollTop - (containerRect.top - elementRect.top),
206+
behavior : "smooth"
207+
});
208+
}
209+
}, 50); // ajoute un délai
205210
} else {
206211
collapse.classList.remove("fr-collapse--expanded");
207212
collapse.classList.add("GPelementHidden");

0 commit comments

Comments
 (0)