From 1028577521a009a9694ef87570b35118cb95ff8b Mon Sep 17 00:00:00 2001 From: Peter Savchenko Date: Sat, 27 Apr 2024 21:04:26 +0300 Subject: [PATCH 1/2] fix(scroll): acidental scroll to top on iOS devices (#2695) * fix scroll on ios typing * Update tsconfig.json * Update CHANGELOG.md * Update CHANGELOG.md * Update package.json * Fix popover hide method to use isHidden flag --- docs/CHANGELOG.md | 6 ++---- package.json | 2 +- src/components/utils/popover/popover-mobile.ts | 13 +++++++++++++ src/components/utils/scroll-locker.ts | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index dae1953b..f2bec70c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,18 +1,16 @@ # Changelog -### 2.30.1 +### 2.30.0 – `New` – Block Tunes now supports nesting items – `New` – Block Tunes now supports separator items – `New` – "Convert to" control is now also available in Block Tunes - -### 2.30.0 - - `Improvement` — The ability to merge blocks of different types (if both tools provide the conversionConfig) - `Fix` — `onChange` will be called when removing the entire text within a descendant element of a block. - `Fix` - Unexpected new line on Enter press with selected block without caret - `Fix` - Search input autofocus loosing after Block Tunes opening - `Fix` - Block removing while Enter press on Block Tunes +– `Fix` – Unwanted scroll on first typing on iOS devices ### 2.29.1 diff --git a/package.json b/package.json index 6df85acf..3da27a8c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@editorjs/editorjs", - "version": "2.30.0-rc.5", + "version": "2.30.0-rc.6", "description": "Editor.js — Native JS, based on API and Open Source", "main": "dist/editorjs.umd.js", "module": "dist/editorjs.mjs", diff --git a/src/components/utils/popover/popover-mobile.ts b/src/components/utils/popover/popover-mobile.ts index 5dd324d8..c309b95c 100644 --- a/src/components/utils/popover/popover-mobile.ts +++ b/src/components/utils/popover/popover-mobile.ts @@ -30,6 +30,11 @@ export class PopoverMobile extends PopoverAbstract { */ private history = new PopoverStatesHistory(); + /** + * Flag that indicates if popover is hidden + */ + private isHidden = true; + /** * Construct the instance * @@ -58,18 +63,26 @@ export class PopoverMobile extends PopoverAbstract { super.show(); this.scrollLocker.lock(); + + this.isHidden = false; } /** * Closes popover */ public hide(): void { + if (this.isHidden) { + return; + } + super.hide(); this.nodes.overlay.classList.add(css.overlayHidden); this.scrollLocker.unlock(); this.history.reset(); + + this.isHidden = true; } /** diff --git a/src/components/utils/scroll-locker.ts b/src/components/utils/scroll-locker.ts index af9a5e86..cc97775c 100644 --- a/src/components/utils/scroll-locker.ts +++ b/src/components/utils/scroll-locker.ts @@ -15,7 +15,7 @@ export default class ScrollLocker { /** * Stores scroll position, used for hard scroll lock */ - private scrollPosition: null|number; + private scrollPosition: null | number = null; /** * Locks body element scroll From c48fca1be3eb59ecc0b35d001ca2667a7a91f2cc Mon Sep 17 00:00:00 2001 From: Peter Savchenko Date: Sat, 27 Apr 2024 21:09:16 +0300 Subject: [PATCH 2/2] fix ios shift (#2696) --- docs/CHANGELOG.md | 1 + src/components/modules/blockEvents.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f2bec70c..222ddad0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,7 @@ - `Fix` - Search input autofocus loosing after Block Tunes opening - `Fix` - Block removing while Enter press on Block Tunes – `Fix` – Unwanted scroll on first typing on iOS devices +- `Fix` - Unwanted soft line break on Enter press after period and space (". |") on iOS devices ### 2.29.1 diff --git a/src/components/modules/blockEvents.ts b/src/components/modules/blockEvents.ts index 88b55ccb..78f23336 100644 --- a/src/components/modules/blockEvents.ts +++ b/src/components/modules/blockEvents.ts @@ -279,8 +279,12 @@ export default class BlockEvents extends Module { /** * Allow to create line breaks by Shift+Enter + * + * Note. On iOS devices, Safari automatically treats enter after a period+space (". |") as Shift+Enter + * (it used for capitalizing of the first letter of the next sentence) + * We don't need to lead soft line break in this case — new block should be created */ - if (event.shiftKey) { + if (event.shiftKey && !_.isIosDevice) { return; }