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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.7.0 RC
    • 5.7.0 Beta
    • Quick: Controls 2
    • None
    • Android 4.4
    • 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

            mitch_curtis Mitch Curtis
            krnekit Nikita Krupenko
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes