ListItem: setting implicitHeight has no effect

Bug #1630683 reported by Andrea Bernabei
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-ui-toolkit (Ubuntu)
New
Undecided
Zsombor Egri

Bug Description

ubuntu-ui-toolkit/staging, r2133

Description:
Creating a ListItem and setting its implicitHeight has no effect.
This means any component that derives from ListItem has to be implemented setting its height, while the best practice (as far as I know) is that components are supposed to set their implicit size, and leave the "real" size to the user of those components.

Investigation:
I spent some time on investigating this already. The problem is:
- http://bazaar.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-toolkit/staging/view/2133/src/UbuntuToolkit/uclistitem.cpp#L1128
This means every time the width of the parent changes, ListItem will reset its implicit height to the default value. As a consequence, specifying a custom implicit height value is not allowed, because any parent's width change would cause it to be overwritten.
- http://bazaar.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-toolkit/staging/view/2133/src/UbuntuToolkit/uclistitem.cpp#L1130 At this point the item has the implicitHeight set by the testcase below. Calling _q_updateSize overwrites what the user set.

Testcase:
import QtQuick 2.4
import Ubuntu.Components 1.3

Item {
    width: units.gu(42)
    height: units.gu(75)
    ListItem {
        id: menu
        Component.onCompleted: console.log(height, implicitHeight)

        //This is overridden on ListItem init and on every parent's width change.
        //It is as if it weren't there
        implicitHeight: 5000

        //Explicitly setting height is the only way to resize the component
        height: 5000

        Rectangle {
            anchors.fill: parent
            color: "blue"
        }
    }
}

Andrea Bernabei (faenil)
Changed in ubuntu-ui-toolkit (Ubuntu):
assignee: nobody → Zsombor Egri (zsombi)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I've noticed all this by using ListItemLayout's as ListItem main child, with variable height...
When resizing the main window, the items were collapsing

See attached videos.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :
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.