Skip to content

Commit

Permalink
fix for content Items not showing if contnent is added after contentRows
Browse files Browse the repository at this point in the history
  • Loading branch information
shanteaustin committed Sep 6, 2024
1 parent 761b5db commit 976868a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class ControlRow extends TitleRow {
_appendItemsAt(items, appendIndex, removeSpacingIndex) {
const itemsCopy = [...items];

if (removeSpacingIndex != undefined) {
if (removeSpacingIndex != undefined && removeSpacingIndex >= 0) {
this.items[removeSpacingIndex].extraItemSpacing = undefined;
itemsCopy[itemsCopy.length - 1].extraItemSpacing =
this.extraItemSpacing == undefined
Expand All @@ -133,6 +133,7 @@ export default class ControlRow extends TitleRow {
}

addContentItems(items) {
const lastSelected = this.selectedIndex;
const itemsToAdd = this._createContentItems(items);
const addIndex = this._lastItemIndex + 1;
this._appendItemsAt(itemsToAdd, addIndex, this._lastItemIndex);
Expand All @@ -142,6 +143,9 @@ export default class ControlRow extends TitleRow {
this._contentItems = [...this.contentItems, ...itemsToAdd];
}

this._updateContent();
this.selectedIndex = lastSelected;

this.patch({
stopLazyScrollIndex: this.leftControls.length + this.items.length - 1
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,42 @@ export const Basic = () =>
}
};

export const Bug = () =>
class Bug extends lng.Component {
static _template() {
return {
ControlRow: {
type: ControlRowComponent,
leftControls: [],
contentItems: [],
rightControls: [],
lazyLoadBuffer: 1
}
};
}

_construct() {
setTimeout(() => {
if (this._ControlRow) {
this._ControlRow.addContentItems(
createItems(
3,
'https://image.tmdb.org/t/p/w500/frwl2zBNAl5ZbFDJGoJv0mYo0rF.jpg'
)
);
}
}, 1500);
}
_getFocused() {
return this.tag('ControlRow');
}

get _ControlRow() {
return this.tag('ControlRow');
}
};


Check failure on line 121 in packages/@lightningjs/ui-components/src/components/ControlRow/ControlRow.stories.js

View workflow job for this annotation

GitHub Actions / quality / lint-unit

Delete `⏎`

Check failure on line 121 in packages/@lightningjs/ui-components/src/components/ControlRow/ControlRow.stories.js

View workflow job for this annotation

GitHub Actions / quality / lint-unit

Delete `⏎`
export const LazyLoading = () =>
class LazyLoading extends lng.Component {
static _template() {
Expand Down

0 comments on commit 976868a

Please sign in to comment.