From 765c4f9704e2b606a94fedff3e3fdf7deeefa2f6 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 30 Dec 2020 16:41:45 -0800 Subject: mobile/UI: fix the logic to keep input visible Using the y coordinate of the component directly doesn't work if we use the component inside other components. Instead we need to grab the position relative to the flickable. The comment about needing the function for this to work seemed dubious. So for now I've removed that function and am setting the position directly. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/SsrfTextField.qml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'mobile-widgets/qml/SsrfTextField.qml') diff --git a/mobile-widgets/qml/SsrfTextField.qml b/mobile-widgets/qml/SsrfTextField.qml index 84b7695b7..deba32a56 100644 --- a/mobile-widgets/qml/SsrfTextField.qml +++ b/mobile-widgets/qml/SsrfTextField.qml @@ -42,15 +42,11 @@ Controls.TextField { return } // make sure there's enough space for the input field above the keyboard and action button (and that it's not too far up, either) - if (stf.y + stf.height > flickable.contentY + flickable.height - 3 * Kirigami.Units.gridUnit || y < flickable.contentY) - ensureVisible(Math.max(0, 3 * Kirigami.Units.gridUnit + stf.y + stf.height - flickable.height)) + var positionInFlickable = stf.mapToItem(flickable.contentItem, 0, 0) + var stfY = positionInFlickable.y + console.log("position check: lower edge of view is " + (0 + flickable.contentY + flickable.height) + " and text field is at " + stfY) + if (stfY + stf.height > flickable.contentY + flickable.height - 3 * Kirigami.Units.gridUnit || stfY < flickable.contentY) + flickable.contentY = Math.max(0, 3 * Kirigami.Units.gridUnit + stfY + stf.height - flickable.height) } } - - // scroll the flickable to the desired position if the keyboard has shown up - // this didn't work when setting it from within the Timer, but calling this function works. - // go figure. - function ensureVisible(yDest) { - flickable.contentY = yDest - } } -- cgit v1.2.3-70-g09d2