From e4384c5434010547104bb1098e8ec521062bd90d Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 20 May 2024 23:10:04 -0400 Subject: [PATCH] fix(ags): reset scroll on opening app and clip --- modules/ags/config/ts/misc/sorted-list.ts | 28 +++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/modules/ags/config/ts/misc/sorted-list.ts b/modules/ags/config/ts/misc/sorted-list.ts index e6a2d48..58a704a 100644 --- a/modules/ags/config/ts/misc/sorted-list.ts +++ b/modules/ags/config/ts/misc/sorted-list.ts @@ -74,10 +74,21 @@ const makeChild = (class_name: string | Binding) => { hexpand: true, }); + const scrollable = Scrollable({ + hscroll: 'never', + vscroll: 'automatic', + child: Box({ + vertical: true, + children: [list, placeholder], + }), + }); + return { list, entry, placeholder, + scrollable, + child: Box({ class_name, vertical: true, @@ -90,14 +101,7 @@ const makeChild = (class_name: string | Binding) => { ], }), - Scrollable({ - hscroll: 'never', - vscroll: 'automatic', - child: Box({ - vertical: true, - children: [list, placeholder], - }), - }), + scrollable, ], }), }; @@ -116,6 +120,7 @@ export class SortedList< private _list: MakeChild['list']; private _entry: MakeChild['entry']; private _placeholder: MakeChild['placeholder']; + private _scrollable: MakeChild['scrollable']; private _on_select: (row: ListBoxRow) => void; private _init_rows: (list: MakeChild['list']) => void; private _set_sort: ( @@ -130,6 +135,10 @@ export class SortedList< fun(this); this._init_rows(this._list); centerCursor(); + + const adjustScroll = this._scrollable.vadjustment; + + this._scrollable.vadjustment.set_value(adjustScroll.lower); this._entry.grab_focus(); }; } @@ -138,7 +147,7 @@ export class SortedList< on_select, init_rows, set_sort, - on_open = () => {/**/}, + on_open = () => { /**/ }, class_name = '', keymode = 'on-demand', ...rest @@ -160,6 +169,7 @@ export class SortedList< this._set_sort = set_sort; this._placeholder = makeChildResult.placeholder; + this._scrollable = makeChildResult.scrollable; this._list = makeChildResult.list; this._list.on('row-activated', (_, row) => {