From 2bf394581f9e9127c720494488952fa09ec35026 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 31 Mar 2020 09:40:28 -0700 Subject: mobile/dive-details: if menu is open, close that with back button A second tap on the back button will then end add/edit or close the dive details and get us back to the dive list. This fixes an issue where tapping on back with the context menu open would bring you back to the dive list with the context menu still open, and because then change the text in the context menu as those are designed differently. Reported-by: Willem Ferguson Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/DiveDetails.qml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml index b102d7206..9970a9455 100644 --- a/mobile-widgets/qml/DiveDetails.qml +++ b/mobile-widgets/qml/DiveDetails.qml @@ -261,15 +261,27 @@ Kirigami.Page { } onBackRequested: { - if (state === "edit") { - endEditMode() - event.accepted = true; - } else if (state === "add") { - endEditMode() - pageStack.pop() - event.accepted = true; + // if one of the drawers/menus is open, the back button should close those + if (globalDrawer.visible) { + globalDrawer.close() + event.accepted = true + } + if (contextDrawer.visible) { + contextDrawer.close() + event.accepted = true + } + // if we didn't close either of the drawer, check if we need to close add/edit + if (event.accepted === false) { + if (state === "edit") { + endEditMode() + event.accepted = true; + } else if (state === "add") { + endEditMode() + pageStack.pop() + event.accepted = true; + } } - // if we were in view mode, don't accept the event and pop the page + // if we were in view mode and no menus are open, don't accept the event and pop the page } onCurrentItemChanged: { -- cgit v1.2.3-70-g09d2