Skip to content

Commit 0b1323f

Browse files
authored
fix(ControlRow): allow items to be added if contentItems is empty (#531)
* fix for content Items not showing if contnent is added after contentRows * lint fix error * removed bug test function"
1 parent 761b5db commit 0b1323f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • packages/@lightningjs/ui-components/src/components/ControlRow

packages/@lightningjs/ui-components/src/components/ControlRow/ControlRow.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default class ControlRow extends TitleRow {
122122
_appendItemsAt(items, appendIndex, removeSpacingIndex) {
123123
const itemsCopy = [...items];
124124

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

135135
addContentItems(items) {
136+
const lastSelected = this.selectedIndex;
136137
const itemsToAdd = this._createContentItems(items);
137138
const addIndex = this._lastItemIndex + 1;
138139
this._appendItemsAt(itemsToAdd, addIndex, this._lastItemIndex);
@@ -142,6 +143,9 @@ export default class ControlRow extends TitleRow {
142143
this._contentItems = [...this.contentItems, ...itemsToAdd];
143144
}
144145

146+
this._updateContent();
147+
this.selectedIndex = lastSelected;
148+
145149
this.patch({
146150
stopLazyScrollIndex: this.leftControls.length + this.items.length - 1
147151
});

0 commit comments

Comments
 (0)