Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 621cc95

Browse files
devversionThomasBurleson
authored andcommitted
fix(list): remove secondary container flex filler.
* Currently the secondary container was pushed to the end of the list-item by using a flex element with auto. This is causing issues with custom content of developers, because the flex filler has a high priority and reserves space. * This can be fixed, by using a margin auto, which has a lower priority and isn't reserving any space. This allows the user to style the content himself and we won't interfere. * The height of 100% for the secondary item container was depending on its parent DOM structure. So in some weird cases, the secondary item container was reserving 100% height of the screen. This property even became unnecessary, because now the secondary items are expecting its size correctly and will fill the remaining space by the auto margin. Fixes #8094. Fixes #7976. Closes #8075
1 parent 8bf174b commit 621cc95

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

src/components/list/list.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ function mdListItemDirective($mdAria, $mdConstant, $mdUtil, $timeout) {
170170
wrapSecondaryItem(secondaryItem, secondaryItemsWrapper);
171171
});
172172

173-
// Since the secondary item container is static we need to fill the remaing space.
174-
var spaceFiller = angular.element('<div class="flex"></div>');
175-
itemContainer.append(spaceFiller);
176-
177173
itemContainer.append(secondaryItemsWrapper);
178174
}
179175

src/components/list/list.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,18 @@ md-list-item {
294294
display: flex;
295295
align-items: center;
296296

297-
height: 100%;
297+
// The secondary container is now static and needs to be aligned at the end of its parent.
298+
// - Using an absolute position will cause much issues with the overflow.
299+
// - Using a flex-filler, which pushes the container to the end of the parent is working
300+
// but breaks the users list-item layout.
301+
// Using margin auto to move them to the end of the list item is more elegant, because it has
302+
// a lower priority than the flex filler and isn't introducing overflow issues again.
303+
// The margin on the top is also important to align multiple secondary items vertical correctly.
298304
margin: auto;
299305

306+
@include rtl(margin-right, 0, auto);
307+
@include rtl(margin-left, auto, 0);
308+
300309
.md-button, .md-icon-button {
301310
&:last-of-type {
302311
// Reset 6px margin for the button.
@@ -346,7 +355,7 @@ md-list-item {
346355
overflow: hidden;
347356

348357
&.md-offset {
349-
@include rtl-prop(margin-left, margin-right, $list-item-primary-width);
358+
@include rtl-prop(margin-left, margin-right, $list-item-primary-width);
350359
}
351360

352361
h3 {

src/components/list/list.spec.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ describe('mdListItem directive', function() {
138138
var buttonWrap = listItem.children().eq(0);
139139
expect(listItem).toHaveClass('_md-button-wrap');
140140

141-
// The button wrap should contain the button executor, the inner content, flex filler and the
141+
// The button wrap should contain the button executor, the inner content and the
142142
// secondary item container as children.
143-
expect(buttonWrap.children().length).toBe(4);
143+
expect(buttonWrap.children().length).toBe(3);
144144

145145
var buttonExecutor = buttonWrap.children()[0];
146146

@@ -164,9 +164,9 @@ describe('mdListItem directive', function() {
164164
var buttonWrap = listItem.children().eq(0);
165165
expect(listItem).toHaveClass('_md-button-wrap');
166166

167-
// The button wrap should contain the button executor, the inner content, flex filler and the
167+
// The button wrap should contain the button executor, the inner content and the
168168
// secondary item container as children.
169-
expect(buttonWrap.children().length).toBe(4);
169+
expect(buttonWrap.children().length).toBe(3);
170170

171171
var buttonExecutor = buttonWrap.children()[0];
172172

@@ -190,9 +190,9 @@ describe('mdListItem directive', function() {
190190
var buttonWrap = listItem.children().eq(0);
191191
expect(listItem).toHaveClass('_md-button-wrap');
192192

193-
// The button wrap should contain the button executor, the inner content, flex filler and the
193+
// The button wrap should contain the button executor, the inner content and the
194194
// secondary item container as children.
195-
expect(buttonWrap.children().length).toBe(4);
195+
expect(buttonWrap.children().length).toBe(3);
196196

197197
var buttonExecutor = buttonWrap.children()[0];
198198

@@ -215,9 +215,9 @@ describe('mdListItem directive', function() {
215215
var buttonWrap = listItem.children().eq(0);
216216
expect(listItem).toHaveClass('_md-button-wrap');
217217

218-
// The button wrap should contain the button executor, the inner content, flex filler and the
218+
// The button wrap should contain the button executor, the inner content and the
219219
// secondary item container as children.
220-
expect(buttonWrap.children().length).toBe(4);
220+
expect(buttonWrap.children().length).toBe(3);
221221

222222
var buttonExecutor = buttonWrap.children()[0];
223223

@@ -256,11 +256,11 @@ describe('mdListItem directive', function() {
256256

257257
expect(listItem).toHaveClass('_md-button-wrap');
258258

259-
// It should contain three elements, the button overlay, inner content, flex filler
259+
// It should contain three elements, the button overlay, inner content
260260
// and the secondary container.
261-
expect(firstChild.children().length).toBe(4);
261+
expect(firstChild.children().length).toBe(3);
262262

263-
var secondaryContainer = firstChild.children().eq(3);
263+
var secondaryContainer = firstChild.children().eq(2);
264264
expect(secondaryContainer).toHaveClass('_md-secondary-container');
265265

266266
// The secondary container should contain the md-icon,
@@ -282,11 +282,11 @@ describe('mdListItem directive', function() {
282282

283283
expect(listItem).toHaveClass('_md-button-wrap');
284284

285-
// It should contain three elements, the button overlay, inner content, flex filler
285+
// It should contain three elements, the button overlay, inner content,
286286
// and the secondary container.
287-
expect(firstChild.children().length).toBe(4);
287+
expect(firstChild.children().length).toBe(3);
288288

289-
var secondaryContainer = firstChild.children().eq(3);
289+
var secondaryContainer = firstChild.children().eq(2);
290290
expect(secondaryContainer).toHaveClass('_md-secondary-container');
291291

292292
// The secondary container should hold the two secondary items.

0 commit comments

Comments
 (0)