Skip to content

Commit

Permalink
fix(scroll): acidental scroll to top on iOS devices (#2695)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
neSpecc authored Apr 27, 2024
1 parent 8442726 commit 1028577
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 2 additions & 4 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 13 additions & 0 deletions src/components/utils/popover/popover-mobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export class PopoverMobile extends PopoverAbstract<PopoverMobileNodes> {
*/
private history = new PopoverStatesHistory();

/**
* Flag that indicates if popover is hidden
*/
private isHidden = true;

/**
* Construct the instance
*
Expand Down Expand Up @@ -58,18 +63,26 @@ export class PopoverMobile extends PopoverAbstract<PopoverMobileNodes> {
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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/scroll-locker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1028577

Please sign in to comment.