From ce15bc202d1ae8ea1af90623932efe662a3b08cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 31 Jul 2019 10:15:31 +0200 Subject: [PATCH] [escher/layout_field] Fix EmptyLayout disappearance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scenario : In the calculation app, write 1, press Enter. •| Write --- 2 Then go up. The empty layout on top of the fraction disappears. --- escher/src/layout_field.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index 0e5d44da3..740ea7bc6 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -156,18 +156,20 @@ bool LayoutField::handleEvent(Ion::Events::Event event) { shouldRecomputeLayout = true; didHandleEvent = true; } - if (didHandleEvent) { - shouldRecomputeLayout = m_contentView.cursor()->hideEmptyLayoutIfNeeded() || shouldRecomputeLayout; - if (!shouldRecomputeLayout) { - m_contentView.cursorPositionChanged(); - scrollToCursor(); - } else { - reload(previousSize); - } - return true; + /* Hide empty layout only if the layout is being edited, otherwise the cursor + * is not visible so any empty layout should be visible. */ + bool didHideLayouts = isEditing() && m_contentView.cursor()->hideEmptyLayoutIfNeeded(); + if (!didHandleEvent) { + return false; } - m_contentView.cursor()->hideEmptyLayoutIfNeeded(); - return false; + shouldRecomputeLayout = didHideLayouts || shouldRecomputeLayout; + if (!shouldRecomputeLayout) { + m_contentView.cursorPositionChanged(); + scrollToCursor(); + } else { + reload(previousSize); + } + return true; } bool LayoutField::privateHandleEvent(Ion::Events::Event event) {