You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue Summary: Attempting the select the first row in an intentionally not-mounted grid will cause a three second mask. A grid may be intentionally not-mounted if something is chosen to render in its place if its store is empty, for example a placeholder component.
When calling selectFirstAsync on a GridModel, it first checks its isReady property, and waits for it to become true if it isn't already. The GridModel's isReady is a trampoline from its AgGridModel's property, which is evaluated based on whether the grid component is fully initialized and mounted.
The awaiting occurs when GridModel's selectFirstAsync calls its whenReadyAsync method, which waits for isReady true, for a default of three seconds. If after the timeout, the grid is still not ready, selectFirstAsync simply returns. The primary purpose of waiting for isReady is to allow a grid component time to mount, if it wasn't already.
In some cases, an app may choose to only mount a grid if it has rows, and display another component, e.g. a placeholder instead. If the app is selecting the first row after loading, then the following will happen after loading the GridModel with no records:
Load the GridModel with no rows.
The grid is not rendered, and another component displayed instead.
Attempt to select the first row in the grid.
Since the grid is not mounted, isReady never turns true.
A three second (default) mask is displayed while the GridModel waits for the grid to mount (which never happens), after which it returns.
This results in what seems like a performance issue when loading an empty grid. A quick workaround is to return in the app's doLoadAsync method after loading the GridModel, and before attempting to select the first row, if no records where loaded. A more robust fix is for selectFirstAsync to know whether the grid component is intentionally not-mounted, return if so, and only await isReady otherwise.
The text was updated successfully, but these errors were encountered:
amcclain
changed the title
GridModel selectFirstAsync should respect intentionally not-mounted grid component
1GridModel.selectFirstAsync` should respect intentionally not-mounted grid component
Apr 22, 2024
amcclain
changed the title
1GridModel.selectFirstAsync` should respect intentionally not-mounted grid componentGridModel.selectFirstAsync should respect intentionally not-mounted grid component
Apr 22, 2024
In your app code, could you simply not await the call to selectFirstAsync? Or (for when there are any rows), do you need to ensure that the first row has been fully selected before that method completes?
That said, it does seem like GridModel could do check at the top of selectFirstAsync and return immediately if its store is empty. I can't think of any reason why that would be a bad idea - or to put it another way, I can't think of any case where GridModel would have a row to select if it's store is empty.
I'd suggest a quick look at any other methods there that await this.whenReadyAsync() to see if the same early-out should be applied elsewhere for consistency.
Issue Summary: Attempting the select the first row in an intentionally not-mounted
grid
will cause a three second mask. Agrid
may be intentionally not-mounted if something is chosen to render in its place if its store is empty, for example aplaceholder
component.When calling
selectFirstAsync
on aGridModel
, it first checks itsisReady
property, and waits for it to becometrue
if it isn't already. TheGridModel
'sisReady
is a trampoline from itsAgGridModel
's property, which is evaluated based on whether thegrid
component is fully initialized and mounted.The awaiting occurs when
GridModel
'sselectFirstAsync
calls itswhenReadyAsync
method, which waits forisReady
true, for a default of three seconds. If after the timeout, the grid is still not ready,selectFirstAsync
simply returns. The primary purpose of waiting forisReady
is to allow agrid
component time to mount, if it wasn't already.In some cases, an app may choose to only mount a
grid
if it has rows, and display another component, e.g. aplaceholder
instead. If the app is selecting the first row after loading, then the following will happen after loading theGridModel
with no records:GridModel
with no rows.grid
is not rendered, and another component displayed instead.grid
.grid
is not mounted,isReady
never turns true.GridModel
waits for thegrid
to mount (which never happens), after which it returns.This results in what seems like a performance issue when loading an empty
grid
. A quick workaround is to return in the app'sdoLoadAsync
method after loading theGridModel
, and before attempting to select the first row, if no records where loaded. A more robust fix is forselectFirstAsync
to know whether thegrid
component is intentionally not-mounted, return if so, and only awaitisReady
otherwise.The text was updated successfully, but these errors were encountered: