From cb77784d2ae73c8f85babc5b058eb7524300d050 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Wed, 30 Sep 2020 10:36:53 +0100 Subject: [PATCH] also restore collapsed state to last user setting --- src/ol/control/Attribution.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ol/control/Attribution.js b/src/ol/control/Attribution.js index 733f5c2a46..682e153021 100644 --- a/src/ol/control/Attribution.js +++ b/src/ol/control/Attribution.js @@ -66,6 +66,12 @@ class Attribution extends Control { this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true; + /** + * @private + * @type {boolean} + */ + this.userCollapsed_ = this.collapsed_; + /** * @private * @type {boolean} @@ -265,6 +271,7 @@ class Attribution extends Control { handleClick_(event) { event.preventDefault(); this.handleToggle_(); + this.userCollapsed_ = this.collapsed_; } /** @@ -300,7 +307,7 @@ class Attribution extends Control { } this.collapsible_ = collapsible; this.element.classList.toggle('ol-uncollapsible'); - if (!collapsible && this.collapsed_) { + if (this.userCollapsed_) { this.handleToggle_(); } } @@ -313,6 +320,7 @@ class Attribution extends Control { * @api */ setCollapsed(collapsed) { + this.userCollapsed_ = collapsed; if (!this.collapsible_ || this.collapsed_ === collapsed) { return; }