@@ -128,11 +128,16 @@ FocusScope {
128128 highlightWhenPressed: false
129129 showDivider: false
130130
131− readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
132− readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filtered : true
131+ readonly property bool expandable: item ? item.uncollapsedHeight > item.collapsedHeight : false
132+ property bool filtered: true
133133 readonly property string category: categoryId
134134 readonly property var item: rendererLoader.item
135135
136+ function setFilter(filter, animate) {
137+ heightBehaviour.enabled = animate;
138+ filtered = filter;
139+ }
140+
136141 CardTool {
137142 id: cardTool
138143 objectName: "cardTool"
@@ -142,6 +147,18 @@ FocusScope {
142147 viewWidth: parent.width
143148 }
144149
150+ onExpandableChanged: {
151+ // This can happen with the VJ that doesn't know how height it will be on creation
152+ // so doesn't set expandable until a bit too late for onLoaded
153+ if (expandable) {
154+ var shouldFilter = baseItem.category != categoryView.expandedCategoryId;
155+ baseItem.setFilter(shouldFilter, false /*animate*/);
156+ }
157+ }
158+
159+ onHeightChanged: rendererLoader.updateDelegateCreationRange();
160+ onYChanged: rendererLoader.updateDelegateCreationRange();
161+
145162 Loader {
146163 id: rendererLoader
147164 anchors {
@@ -151,13 +168,27 @@ FocusScope {
151168 topMargin: hasSectionHeader ? 0 : units.gu(2)
152169 }
153170
171+ Behavior on height {
172+ id: heightBehaviour
173+ enabled: false
174+ animation: UbuntuNumberAnimation {
175+ onRunningChanged: {
176+ if (!running) {
177+ heightBehaviour.enabled = false
178+ }
179+ }
180+ }
181+ }
182+
183+ height: baseItem.filtered ? item.collapsedHeight : item.uncollapsedHeight
184+
154185 source: {
155186 switch (cardTool.categoryLayout) {
156187 case "carousel": return "CardCarousel.qml";
157188 case "vertical-journal": return "CardVerticalJournal.qml";
158189 case "running-apps": return "Apps/RunningApplicationsGrid.qml";
159190 case "grid":
160− default: return "CardFilterGrid.qml";
191+ default: return "CardGrid.qml";
161192 }
162193 }
163194
@@ -176,9 +207,9 @@ FocusScope {
176207 }
177208 item.objectName = Qt.binding(function() { return categoryId })
178209 item.scopeStyle = scopeView.scopeStyle;
179− if (item.expandable) {
210+ if (baseItem.expandable) {
180211 var shouldFilter = categoryId != categoryView.expandedCategoryId;
181− item.setFilter(shouldFilter, false /*animate*/);
212+ baseItem.setFilter(shouldFilter, false /*animate*/);
182213 }
183214 updateDelegateCreationRange();
184215 item.cardTool = cardTool;
@@ -211,14 +242,6 @@ FocusScope {
211242 previewListView.currentIndex = index;
212243 previewListView.open = true
213244 }
214− onExpandableChanged: {
215− // This can happen with the VJ that doesn't know how height it will be on creation
216− // so doesn't set expandable until a bit too late for onLoaded
217− if (rendererLoader.item.expandable) {
218− var shouldFilter = baseItem.category != categoryView.expandedCategoryId;
219− rendererLoader.item.setFilter(shouldFilter, false /*animate*/);
220− }
221− }
222245 }
223246 Connections {
224247 target: categoryView
@@ -227,15 +250,15 @@ FocusScope {
227250 }
228251 function collapseAllButExpandedCategory() {
229252 var item = rendererLoader.item;
230− if (item.expandable) {
253+ if (baseItem.expandable) {
231254 var shouldFilter = categoryId != categoryView.expandedCategoryId;
232− if (shouldFilter != item.filter) {
255+ if (shouldFilter != baseItem.filtered) {
233256 // If the filter animation will be seen start it, otherwise, just flip the switch
234257 var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
235258 var growingVisible = !shouldFilter && y + height < categoryView.height;
236259 if (!previewListView.open || !shouldFilter) {
237260 var animate = shrinkingVisible || growingVisible;
238− item.setFilter(shouldFilter, animate)
261+ baseItem.setFilter(shouldFilter, animate)
239262 if (!shouldFilter && !previewListView.open) {
240263 categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
241264 }
@@ -304,9 +327,6 @@ FocusScope {
304327 z: -1
305328 }
306329 }
307−
308− onHeightChanged: rendererLoader.updateDelegateCreationRange();
309− onYChanged: rendererLoader.updateDelegateCreationRange();
310330 }
311331
312332 sectionProperty: "name"