From 03e302cbf68cc502a2b6bef0726186a0b3ef321c Mon Sep 17 00:00:00 2001 From: Alexander Fuks Date: Sun, 13 Oct 2024 21:16:25 +0400 Subject: [PATCH] chore: close toc-popup gracefully with Esc key (#1990) --- _javascript/modules/components/toc/toc-mobile.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_javascript/modules/components/toc/toc-mobile.js b/_javascript/modules/components/toc/toc-mobile.js index 48b372df443..8d717dd006e 100644 --- a/_javascript/modules/components/toc/toc-mobile.js +++ b/_javascript/modules/components/toc/toc-mobile.js @@ -62,7 +62,11 @@ export class TocMobile { activeItem.scrollIntoView({ block: 'center' }); } - static hidePopup() { + static hidePopup(event) { + if (event?.type === 'cancel') { + event.preventDefault(); + } + if (!$popup.open) { return; }