glue-viz / glue

Linked Data Visualizations Across Multiple Files
http://glueviz.org
Other
742 stars 153 forks source link

Only recreate table model when Data layer changes #2372

Closed Carifio24 closed 1 year ago

Carifio24 commented 1 year ago

This PR implements a change(/bugfix?) requested by @aagoodman. Currently, after a user makes a selection to create a new subset after having sorted the table, the sorting is undone once the subset is created. This leads to a not-great UX - if one is trying to create multiple selections based on a column's values, having to re-sort each time is annoying.

The reason for this is that the table model is recreated any time the layers change, which resets any sorting. This PR modifies the layer changed callback to only recreate the table model if the actual Data layer has changed - otherwise, we just call the model's _update_visible. This also necessitates making the masks in _update_visible aware of the current order.

Carifio24 commented 1 year ago

Rebased to get CI fixes

astrofrog commented 1 year ago

@Carifio24 - do you think it would be easy to add a test for this, or would it be non-trivial?

Carifio24 commented 1 year ago

@astrofrog I think it should actually be pretty straightforward. I'll try adding one and see if that is indeed the case.

Carifio24 commented 1 year ago

@astrofrog I just added a test - it creates a new subset and checks that the table model and the row ordering are preserved afterwards.