Skip to content

Commit a1e121a

Browse files
fix: hide extension close button when backend close button is available
1 parent c3d04f7 commit a1e121a

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

Resources/Public/JavaScript/contextual_edit.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@
8282
this.sidebar.setAttribute('aria-label', 'Edit content');
8383

8484
// 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);
9292

9393
// Loading spinner
9494
this.loader = document.createElement('div');
@@ -168,6 +168,7 @@
168168
this.hasSaved = false;
169169
this.savedRecordTitle = null;
170170
this.targetBlank = targetBlank || false;
171+
this.closeButton.style.display = '';
171172
this.loader.classList.add('frontend-edit__sidebar-loader--visible');
172173
this.iframe.classList.remove('frontend-edit__sidebar-iframe--loaded');
173174
this.backdrop.classList.add('frontend-edit__sidebar-backdrop--visible');
@@ -268,6 +269,16 @@
268269

269270
if (closeBtn) {
270271
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';
271282
} else {
272283
actionsBar.appendChild(saveCloseBtn);
273284
}

0 commit comments

Comments
 (0)