@@ -141,15 +141,8 @@ def compose(self) -> ComposeResult:
141141 ),
142142 # These are almost identical to create tab
143143 Label ("Datatype(s)" , id = "transfer_datatype_label" ),
144- DatatypeCheckboxes (
145- self .interface ,
146- create_or_transfer = "transfer" ,
147- id = "transfer_custom_datatype_checkboxes" ,
148- ),
149- Button (
150- "Displayed Datatypes" ,
151- id = "transfer_tab_displayed_datatypes_button" ,
152- ),
144+ self .get_datatypes_checkboxes_widget (),
145+ self .get_displayed_datatypes_button (),
153146 ]
154147
155148 yield TransferStatusTree (
@@ -325,11 +318,28 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
325318 )
326319
327320 async def refresh_after_datatype_changed (self , ignore ):
328- """Refresh Checkboxes after the shown datatypes have changed."""
329- await self .recompose ()
330- self .on_mount ()
331- self .query_one ("#transfer_custom_radiobutton" ).value = True
332- self .switch_transfer_widgets_display ()
321+ """Refresh Checkboxes after the shown datatypes have changed.
322+
323+ The widget must be completely removed and reinitialised.
324+ This means the button underneath it must also be removed and
325+ re-added, or it ends up above the datatype checkbox widget.
326+ """
327+ container = self .query_one ("#transfer_params_container" )
328+ await container .query_one (
329+ "#transfer_custom_datatype_checkboxes"
330+ ).remove ()
331+ await container .query_one (
332+ "#transfer_tab_displayed_datatypes_button"
333+ ).remove ()
334+
335+ (
336+ Button (
337+ "Displayed Datatypes" ,
338+ id = "transfer_tab_displayed_datatypes_button" ,
339+ ),
340+ )
341+ await container .mount (self .get_datatypes_checkboxes_widget ())
342+ await container .mount (self .get_displayed_datatypes_button ())
333343
334344 def on_custom_directory_tree_directory_tree_special_key_press (
335345 self , event : CustomDirectoryTree .DirectoryTreeSpecialKeyPress
@@ -411,3 +421,18 @@ def transfer_data(self) -> Worker[InterfaceOutput]:
411421 self .app .call_from_thread (self .reload_directorytree )
412422
413423 return success , output
424+
425+ def get_datatypes_checkboxes_widget (self ):
426+ """Create the datatype checkboxes, centralised as used in multiple places."""
427+ return DatatypeCheckboxes (
428+ self .interface ,
429+ create_or_transfer = "transfer" ,
430+ id = "transfer_custom_datatype_checkboxes" ,
431+ )
432+
433+ def get_displayed_datatypes_button (self ):
434+ """Create the datatype button, centralised as used in multiple places."""
435+ return Button (
436+ "Displayed Datatypes" ,
437+ id = "transfer_tab_displayed_datatypes_button" ,
438+ )
0 commit comments