Page MenuHomeElementl

[dagit] Fix multi-repo switcher localStorage
ClosedPublic

Authored by dish on Mar 22 2021, 2:10 PM.

Details

Summary

Repair an issue with localStorage in the multi-repo switcher.

When the localStorage value doesn't match any of the loaded repos, we fall back to the first option in the list. Unfortunately, this is causing a bug where changing the filter option will unselect the first option. This shouldn't happen, as toggling on one repo should never toggle off another. The issue here is that the list of selected keys is not in sync with the list of options.

To repair this, check the list of matching options immediately upon creating the hook state. In the case where there are no matches, choose the key for the first loaded option.

This requires that state is not determined until the workspace query is finished loading. To that end, split up the component so that the hook only runs when options have loaded.

Test Plan

Set a bogus repo key in localStorage, reload dagit with a multi-repo workspace. Verify that the first option is selected by default, and verify that selecting other repos does not deselect the first option. Check localStorage in the console, verify that it is correct.

Repeat with empty workspace, verify that things look fine.

Diff Detail

Repository
R1 dagster
Lint
Lint Not Applicable
Unit
Tests Not Applicable