Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-53451

Drawer/Popup doesn't regain active focus on children active focus lost

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.7.0 Beta
    • Fix Version/s: 5.7.0 RC
    • Component/s: Quick: Controls 2
    • Labels:
      None
    • Environment:
      Android 4.4
    • Commits:
      9a1c9459a61cdd3ddb1bd0608a2caa9bae632e58

      Description

      Consider simple test program:

      Page {
          Drawer {
              height: parent.height
              width: 300
              onActiveFocusChanged: console.log("drawer", activeFocus)
      
              ComboBox {
                  model: [ "111", "222" ]
                  onActiveFocusChanged: console.log("combobox", activeFocus)
              }
          }
      }
      

      After opening drawer It gain active focus. After click on combobox, it gain active focus true. But after click on drawer, both drawer and combobox lose active focus.

      One more example to illustrate problem.
      I tried to fix some not handling of the back key on mobile devices in https://codereview.qt-project.org/159398 And it works fine for popups, drawers and comboboxes. But, if there is a combobox in a drawer, it doesn't work after I click on combobox: I can close combobox by using Back key, but next time I press this key, it doesn't pass to the drawer, as expected, but proceed to the drawer's parent, and close application, if I don't handle it.
      To reproduce, run next program on mobile device, click on "push", open drawer, click on combobox. Press back - combobox should close. Press back again and page with drawer should disappear, but overlay still here (another bug?), see attached screenshot.

      import QtQuick 2.6
      import QtQuick.Controls 2.0
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
      
          Component {
              id: second
      
      Page {
          Drawer {
              height: parent.height
              width: 300
              onActiveFocusChanged: console.log("drawer", activeFocus)
      
              ComboBox {
                  model: [ "111", "222" ]
                  onActiveFocusChanged: console.log("combobox", activeFocus)
              }
          }
      }
          }
      
          FocusScope {
              anchors.fill: parent
              focus: true
      
              Keys.onBackPressed: {
                  console.log("back")
                  stackView.pop()
              }
      
              Rectangle {
                  id: first
      
                  color: "orange"
              }
      
              StackView {
                  id: stackView
      
                  anchors.fill: parent
                  anchors.bottomMargin: 50
                  initialItem: first
              }
      
              Button {
                  anchors.bottom: parent.bottom
                  text: "push"
                  onClicked: stackView.push(second)
              }
          }
      }
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              mitch_curtis Mitch Curtis
              Reporter:
              krnekit Nikita Krupenko
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes