@@ -78,12 +78,6 @@ def __init__(self, dataframe: bigframes.dataframe.DataFrame):
7878
7979 super ().__init__ ()
8080
81- # This flag prevents observers from firing during initialization.
82- # When traitlets like `page` and `page_size` are set in `__init__`, we
83- # don't want their corresponding `_..._changed` methods to execute
84- # until the widget is fully constructed.
85- self ._initializing = True
86-
8781 # Initialize attributes that might be needed by observers first
8882 self ._table_id = str (uuid .uuid4 ())
8983 self ._all_data_loaded = False
@@ -111,8 +105,10 @@ def __init__(self, dataframe: bigframes.dataframe.DataFrame):
111105
112106 # get the initial page
113107 self ._set_table_html ()
108+
109+ # Signals to the frontend that the initial data load is complete.
110+ # Also used as a guard to prevent observers from firing during initialization.
114111 self ._initial_load_complete = True
115- self ._initializing = False
116112
117113 @functools .cached_property
118114 def _esm (self ):
@@ -242,14 +238,14 @@ def _set_table_html(self) -> None:
242238 @traitlets .observe ("page" )
243239 def _page_changed (self , _change : Dict [str , Any ]) -> None :
244240 """Handler for when the page number is changed from the frontend."""
245- if self ._initializing :
241+ if not self ._initial_load_complete :
246242 return
247243 self ._set_table_html ()
248244
249245 @traitlets .observe ("page_size" )
250246 def _page_size_changed (self , _change : Dict [str , Any ]) -> None :
251247 """Handler for when the page size is changed from the frontend."""
252- if self ._initializing :
248+ if not self ._initial_load_complete :
253249 return
254250 # Reset the page to 0 when page size changes to avoid invalid page states
255251 self .page = 0
0 commit comments