Skip to content

Commit

Permalink
Merge branch 'develop' into feat/preload-keyboards
Browse files Browse the repository at this point in the history
  • Loading branch information
Carolyn Moneymaker committed Sep 16, 2024
2 parents fa178a1 + a914066 commit 0edd515
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 139 deletions.
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 @@ -219,6 +219,7 @@ export default class MetadataCardContent extends MetadataBase {
_resolveProvider() {
this._providerPromiseResolver && this._providerPromiseResolver();
this._updatePositions();
this._updateDetails();
}

_updatePositions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ declare namespace ScrollWrapper {
*/
showScrollBar?: boolean;
}

export interface TypeConfig extends lng.Component.TypeConfig {
SignalMapType: SignalMap;
}

export type SignalMap = {
/**
* emitted when user is at the top of the content and presses up again
*/
onUpAtTop(): void;

/**
* emitted when user is at the bottom of the content and presses bottom again
*/
onDownAtBottom(): void;
};
}

declare class ScrollWrapper<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ export default class ScrollWrapper extends Base {
this.fireAncestors('$scrollChanged', 'endDown', this);
this._updateFadeContainer();
}
} else {
this.signal('onDownAtBottom');
}
}

Expand Down Expand Up @@ -278,6 +280,8 @@ export default class ScrollWrapper extends Base {
this._isEndContentVisible = false;
this._updateFadeContainer();
}
} else {
this.signal('onUpAtTop');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,13 @@ Resets the `y` value of both the content and the scroll bar.
#### $scrollChanged('endUp'|'endDown', this)

Event fired via `fireAncestors`, is triggered when scroll reaches the top or bottom of the scroll boundaries.

### Signals

#### onUpAtTop

Fired when user is at the top of the content within the ScrollWrapper and presses up again.

#### onDownAtBottom

Fired when user is at the bottom of the content within the ScrollWrapper and presses down again.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,27 @@ describe('ScrollWrapper', () => {
);
});

it('should fire a signal when pressing Up when already at the top of the scroll container', () => {
jest.spyOn(scrollWrapper, 'signal');
expect(scrollWrapper.signal).not.toHaveBeenCalled();

testRenderer.keyPress('Up');
testRenderer.update();
expect(scrollWrapper.signal).toHaveBeenCalledWith('onUpAtTop');
});

it('should fire a signal when pressing Down when already at the bottom of the scroll container', () => {
jest.spyOn(scrollWrapper, 'signal');
expect(scrollWrapper.signal).not.toHaveBeenCalled();

// Simulate scrolling to the bottom and then some
for (let i = 0; i < 50; i++) {
testRenderer.keyPress('Down');
testRenderer.update();
}
expect(scrollWrapper.signal).toHaveBeenCalledWith('onDownAtBottom');
});

it('should scroll up by the scroll step', () => {
scrollWrapper.scrollStep = 100;
testRenderer.keyPress('Down');
Expand Down
Loading

0 comments on commit 0edd515

Please sign in to comment.