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; }