diff --git a/CODEOWNERS b/CODEOWNERS index aaa5e0be..d2625662 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1,2 @@ -* @neSpecc @gohabereg @khaydarov +* @neSpecc @gohabereg @TatianaFomina @ilyamore88 + diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 5b3af79e..fd91f853 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,7 +4,9 @@ - `Fix` — Scrolling issue when opening toolbox on mobile fixed - `Fix` — Typo in toolbox empty placeholder fixed +- `Fix` — The issue with scroll jumping on block hovering have fixed [2036](https://github.com/codex-team/editor.js/issues/2036) - `Improvement` — *Dev Example Page* - Add popup example page +- `Improvement` — *UI* - The Toolbox will restore the internal scroll on every opening ### 2.24.1 diff --git a/src/components/utils/popover.ts b/src/components/utils/popover.ts index 1f084324..0a2c30c7 100644 --- a/src/components/utils/popover.ts +++ b/src/components/utils/popover.ts @@ -58,6 +58,11 @@ export default class Popover extends EventsDispatcher { */ private readonly items: PopoverItem[]; + /** + * Stores the visibility state. + */ + private isShown = false; + /** * Created nodes */ @@ -190,6 +195,12 @@ export default class Popover extends EventsDispatcher { * Shows the Popover */ public show(): void { + /** + * Clear search and items scrolling + */ + this.search.clear(); + this.nodes.items.scrollTop = 0; + this.nodes.popover.classList.add(Popover.CSS.popoverOpened); this.nodes.overlay.classList.remove(Popover.CSS.popoverOverlayHidden); this.flipper.activate(); @@ -203,13 +214,22 @@ export default class Popover extends EventsDispatcher { if (isMobileScreen()) { this.scrollLocker.lock(); } + + this.isShown = true; } /** * Hides the Popover */ public hide(): void { - this.search.clear(); + /** + * If it's already hidden, do nothing + * to prevent extra DOM operations + */ + if (!this.isShown) { + return; + } + this.nodes.popover.classList.remove(Popover.CSS.popoverOpened); this.nodes.overlay.classList.add(Popover.CSS.popoverOverlayHidden); this.flipper.deactivate(); @@ -217,6 +237,8 @@ export default class Popover extends EventsDispatcher { if (isMobileScreen()) { this.scrollLocker.unlock(); } + + this.isShown = false; } /**