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 composingTopic = false;
|
||||
|
||||
export function isWorkaroundActive() {
|
||||
return workaroundActive;
|
||||
|
@ -129,11 +128,24 @@ function positioningWorkaround($fixedElement) {
|
|||
if (fixedElement.style.top === "0px") {
|
||||
if (this !== document.activeElement) {
|
||||
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();
|
||||
let _this = this;
|
||||
setTimeout(function() {
|
||||
_this.style.transform = "none";
|
||||
}, 50);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// don't trigger keyboard on disabled element (happens when a category is required)
|
||||
if (this.disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
originalScrollTop = $(window).scrollTop();
|
||||
|
||||
// take care of body
|
||||
|
@ -153,9 +165,7 @@ function positioningWorkaround($fixedElement) {
|
|||
|
||||
fixedElement.style.top = "0px";
|
||||
|
||||
composingTopic = $("#reply-control .category-chooser").length > 0;
|
||||
|
||||
const height = calcHeight(composingTopic);
|
||||
const height = calcHeight();
|
||||
fixedElement.style.height = height + "px";
|
||||
|
||||
$(fixedElement).addClass("no-transition");
|
||||
|
|
Loading…
Reference in New Issue