aiidalab / aiidalab-widgets-base

Reusable widgets for AiiDAlab applications
MIT License
6 stars 17 forks source link

`_StructureDataBaseViewer` consider resetting `input_selection` trait when the structure is modified. #531

Open yakutovicha opened 8 months ago

yakutovicha commented 8 months ago

Currently, the issue with input_selection trait is that one cannot just assign to it a copy of the list with the same content:

selection = copy(self.input_selection)
self.input_selection = selection

This won't trigger the trait observers (not sure why 🤷 ).

So the solution we currently use is the following:

selection = copy(self.input_selection)
self.input_selection = None
self.input_selection = selection

This creates a lot of unnecessary code and increases the risk of errors. We should try to come up with a more general solution.