|
82 | 82 | this.sidebar.setAttribute('aria-label', 'Edit content'); |
83 | 83 |
|
84 | 84 | // Close button |
85 | | - var closeButton = document.createElement('button'); |
86 | | - closeButton.type = 'button'; |
87 | | - closeButton.className = 'frontend-edit__sidebar-close'; |
88 | | - closeButton.setAttribute('aria-label', 'Close editor'); |
89 | | - closeButton.innerHTML = CLOSE_ICON; |
90 | | - closeButton.addEventListener('click', this.requestClose.bind(this)); |
91 | | - this.sidebar.appendChild(closeButton); |
| 85 | + this.closeButton = document.createElement('button'); |
| 86 | + this.closeButton.type = 'button'; |
| 87 | + this.closeButton.className = 'frontend-edit__sidebar-close'; |
| 88 | + this.closeButton.setAttribute('aria-label', 'Close editor'); |
| 89 | + this.closeButton.innerHTML = CLOSE_ICON; |
| 90 | + this.closeButton.addEventListener('click', this.requestClose.bind(this)); |
| 91 | + this.sidebar.appendChild(this.closeButton); |
92 | 92 |
|
93 | 93 | // Loading spinner |
94 | 94 | this.loader = document.createElement('div'); |
|
168 | 168 | this.hasSaved = false; |
169 | 169 | this.savedRecordTitle = null; |
170 | 170 | this.targetBlank = targetBlank || false; |
| 171 | + this.closeButton.style.display = ''; |
171 | 172 | this.loader.classList.add('frontend-edit__sidebar-loader--visible'); |
172 | 173 | this.iframe.classList.remove('frontend-edit__sidebar-iframe--loaded'); |
173 | 174 | this.backdrop.classList.add('frontend-edit__sidebar-backdrop--visible'); |
|
268 | 269 |
|
269 | 270 | if (closeBtn) { |
270 | 271 | actionsBar.insertBefore(saveCloseBtn, closeBtn); |
| 272 | + |
| 273 | + // Wire backend close button to close the sidebar |
| 274 | + closeBtn.addEventListener('click', function (e) { |
| 275 | + e.preventDefault(); |
| 276 | + e.stopImmediatePropagation(); |
| 277 | + self.requestClose(); |
| 278 | + }); |
| 279 | + |
| 280 | + // Hide extension's own close button to avoid overlap |
| 281 | + self.closeButton.style.display = 'none'; |
271 | 282 | } else { |
272 | 283 | actionsBar.appendChild(saveCloseBtn); |
273 | 284 | } |
|
0 commit comments