Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e768e9

Browse files
committed
[WebProfilerBundle] Close profiler settings on escape
1 parent 1f7bc10 commit 7e768e9

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/settings.html.twig

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
height: 100%;
5050
justify-content: center;
5151
left: 0;
52-
opacity: 1;
52+
opacity: 0;
5353
overflow: auto;
5454
position: fixed;
5555
top: 0;
@@ -195,7 +195,7 @@
195195
<div class="modal-container">
196196
<div class="modal-header">
197197
<h3>Configuration Settings</h3>
198-
<button class="close-modal">&times;</button>
198+
<button aria-label="Close" class="close-modal">&times;</button>
199199
</div>
200200

201201
<div class="modal-content">
@@ -282,22 +282,30 @@
282282
const openModalButton = document.getElementById('open-settings');
283283
const modalWindow = document.getElementById('profiler-settings');
284284
const closeModalButton = document.getElementsByClassName('close-modal')[0];
285-
const modalWrapper = document.getElementsByClassName('modal-wrap')[0]
285+
const modalWrapper = document.getElementsByClassName('modal-wrap')[0];
286+
const closeModal = () => {
287+
modalWindow.classList.remove('visible');
288+
setTimeout(() => openModalButton.focus(), 30);
289+
};
286290
287291
openModalButton.addEventListener('click', function(event) {
288292
document.getElementById('settings-' + (localStorage.getItem('symfony/profiler/theme') || 'theme-auto')).checked = 'checked';
289293
document.getElementById('settings-' + (localStorage.getItem('symfony/profiler/width') || 'width-normal')).checked = 'checked';
290294
291295
modalWindow.classList.toggle('visible');
296+
setTimeout(() => closeModalButton.focus(), 30);
292297
event.preventDefault();
293298
});
294299
295-
closeModalButton.addEventListener('click', function() {
296-
modalWindow.classList.remove('visible');
297-
});
300+
closeModalButton.addEventListener('click', closeModal);
298301
modalWrapper.addEventListener('click', function(event) {
299302
if (event.target == event.currentTarget) {
300-
modalWindow.classList.remove('visible');
303+
closeModal();
304+
}
305+
});
306+
modalWrapper.addEventListener('keydown', function(event) {
307+
if (event.key === 'Esc' || event.key === 'Escape') {
308+
closeModal();
301309
}
302310
});
303311
})();

0 commit comments

Comments
 (0)