The rename textfield is not focused

Bug #1361744 reported by Leo Arias
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu File Manager App
Fix Released
Medium
Arto Jalkanen
Ubuntu UI Toolkit
Invalid
Undecided
Zsombor Egri

Bug Description

It would be nice if when you open the rename dialog, the textfield was automatically focused.

To reproduce:
Open filemanager.
Long press on any folder.
Select Rename.
(now you have to click the textfield on the dialog in order to update it.)

Related branches

Arto Jalkanen (ajalkane)
Changed in ubuntu-filemanager-app:
importance: Undecided → Medium
Arto Jalkanen (ajalkane)
Changed in ubuntu-filemanager-app:
status: New → Confirmed
assignee: nobody → Arto Jalkanen (ajalkane)
Revision history for this message
Arto Jalkanen (ajalkane) wrote :

I'm pretty sure this used to work. I suspect this is SDK related bug, could one of the SDK guys take a look?

Basically it seems the focus property in Ubuntu's TextField component is not working. FileManager has code like this:

    TextField {
        id: input
        objectName: "inputField"
        focus: true
    }

But when creating that component this TextField does not have focus.

Changed in ubuntu-filemanager-app:
assignee: Arto Jalkanen (ajalkane) → Ubuntu SDK team (ubuntu-sdk-team)
Zsombor Egri (zsombi)
Changed in ubuntu-ui-toolkit:
assignee: nobody → Zsombor Egri (zsombi)
Zsombor Egri (zsombi)
Changed in ubuntu-ui-toolkit:
status: New → Confirmed
Revision history for this message
Zsombor Egri (zsombi) wrote :

So far focus was taken only by text inputs. Now that we have focus handling, a simple focus: true does not mean that activeFocus will also be taken when a previous component was having focus.

When the popover is long-pressed, it takes the focus, and then when closed, popover restores the focus to its "caller" that being the list item in the file list. So when the Dialog is opened, the list item is the active focus. In order to grab the focus you need to call forceActiveFocus() on Dialog completion. See the following code:

import QtQuick 2.2
import Ubuntu.Components 1.1
import Ubuntu.Components.Popups 1.0
import Ubuntu.Components.ListItems 1.0

MainView {
    width: units.gu(40)
    height: units.gu(71)

    Connections {
        target: window
        onActiveFocusItemChanged: print("activeFocus:", window.activeFocusItem)
    }

    Standard {
        id: caller
        objectName: "MainListItem"
        text: "Press to open popover"
        onClicked: PopupUtils.open(popoverComponent, caller)
    }

    Component {
        id: popoverComponent
        Popover {
            id: popover
            contentWidth: units.gu(20)
            contentHeight: line.height
            Standard {
                id: line
                objectName: "PopoverListItem"
                text: "Open dialog"
                onClicked: {
                    PopupUtils.close(popover)
                    PopupUtils.open(inputDialogComponent)
                }
            }
        }
    }

    Component {
        id: inputDialogComponent
        Dialog {
            id: inputDialog

            title: "Input Dialog"

            TextField {
                id: input
                text: "some text"
                focus: true
            }

            Button {
                text: "Close"
                onClicked: PopupUtils.close(inputDialog)
            }

// Component.onCompleted: input.forceActiveFocus()
        }
    }
}

Changed in ubuntu-ui-toolkit:
status: Confirmed → Invalid
Revision history for this message
Zsombor Egri (zsombi) wrote :

Ok, some correction on the wordings above, somehow I managed to select-delete some text from it :/.

So, what I wanted to say above is that when the long press happens over the file list, the focus is grabbed when the list item is pressed and thus the Popover is opened having the active list item as active focus. Selecting "Rename" from the Popover also grabs the focus, but when the Popover is closed, the focus is restored to its caller (so the Dialog does the same when closed, if the component exists). When the Dialog is opened, the active focus is the list item from the popover, and therefore the "focus: true" assignment is not going to be enough. You must call input.forceActiveFocus() on Dialog completion to grab the focus.

Revision history for this message
Arto Jalkanen (ajalkane) wrote :

> Now that we have focus handling, a simple focus: true does not mean that activeFocus will also be taken when a previous
> component was having focus.

Thank you. I had completely forgotten about these changes. Thanks for the code example, I will fix accordingly.

Changed in ubuntu-filemanager-app:
assignee: Ubuntu SDK team (ubuntu-sdk-team) → Arto Jalkanen (ajalkane)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

Fix committed into lp:ubuntu-filemanager-app at revision 272, scheduled for release in ubuntu-filemanager-app, milestone alpha-1

Changed in ubuntu-filemanager-app:
status: Confirmed → Fix Committed
David Planella (dpm)
Changed in ubuntu-filemanager-app:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.