FIX: Mobile Safari composer improvements (#8069)
- prevents keyboard from being invoked when textarea is disabled - avoids scrolling up when switching focus from title to textarea on new topic creation
This commit is contained in:
parent
82c5a1d20f
commit
21e5772aa5
|
@ -63,7 +63,6 @@ function calcHeight() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let workaroundActive = false;
|
let workaroundActive = false;
|
||||||
let composingTopic = false;
|
|
||||||
|
|
||||||
export function isWorkaroundActive() {
|
export function isWorkaroundActive() {
|
||||||
return workaroundActive;
|
return workaroundActive;
|
||||||
|
@ -129,11 +128,24 @@ function positioningWorkaround($fixedElement) {
|
||||||
if (fixedElement.style.top === "0px") {
|
if (fixedElement.style.top === "0px") {
|
||||||
if (this !== document.activeElement) {
|
if (this !== document.activeElement) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
||||||
|
// this tricks safari into assuming current input is at top of the viewport
|
||||||
|
// via https://stackoverflow.com/questions/38017771/mobile-safari-prevent-scroll-page-when-focus-on-input
|
||||||
|
this.style.transform = "translateY(-200px)";
|
||||||
this.focus();
|
this.focus();
|
||||||
|
let _this = this;
|
||||||
|
setTimeout(function() {
|
||||||
|
_this.style.transform = "none";
|
||||||
|
}, 50);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't trigger keyboard on disabled element (happens when a category is required)
|
||||||
|
if (this.disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
originalScrollTop = $(window).scrollTop();
|
originalScrollTop = $(window).scrollTop();
|
||||||
|
|
||||||
// take care of body
|
// take care of body
|
||||||
|
@ -153,9 +165,7 @@ function positioningWorkaround($fixedElement) {
|
||||||
|
|
||||||
fixedElement.style.top = "0px";
|
fixedElement.style.top = "0px";
|
||||||
|
|
||||||
composingTopic = $("#reply-control .category-chooser").length > 0;
|
const height = calcHeight();
|
||||||
|
|
||||||
const height = calcHeight(composingTopic);
|
|
||||||
fixedElement.style.height = height + "px";
|
fixedElement.style.height = height + "px";
|
||||||
|
|
||||||
$(fixedElement).addClass("no-transition");
|
$(fixedElement).addClass("no-transition");
|
||||||
|
|
Loading…
Reference in New Issue