Skip to content

Commit e6a1d36

Browse files
bmd3kyatbear
authored andcommitted
Fix "Card Width" property reset button. (#5841)
The reset button for "Card Width" does not effectively reset the property. Pressing it resets it to the value that it was set to when the page was loaded. (So, for example, if the value is 535px on page load, pressing reset will reset it to 535px and not reset the property entirely). The reasoning is: * Pressing the reset button will remove the property from state, effectively making it undefined: * https://cs.opensource.google/tensorflow/tensorboard/+/master:tensorboard/webapp/metrics/store/metrics_reducers.ts;l=709;drc=2059b53ef0f6875dbaa8bca4362653c07d0069fd * The PersistentSettingsDataSource does not update the field in local storage if the value is undefined: * https://cs.opensource.google/tensorflow/tensorboard/+/master:tensorboard/webapp/persistent_settings/_data_source/persistent_settings_data_source.ts;l=87;drc=54be1df836817d1a5a6378902eec23a9fe5cb40d * And, so, the value will continue to be whatever was stored in local storage on page load. We fix the problem by setting the state value to null rather than removing it entirely. This means it will also be set to null in local storage and effectively reset the property.
1 parent 1648ec1 commit e6a1d36

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tensorboard/webapp/metrics/store/metrics_reducers.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,10 +707,12 @@ const reducer = createReducer(
707707
};
708708
}),
709709
on(actions.metricsResetCardWidth, (state) => {
710-
const {cardMinWidth, ...nextOverride} = state.settingOverrides;
711710
return {
712711
...state,
713-
settingOverrides: nextOverride,
712+
settingOverrides: {
713+
...state.settingOverrides,
714+
cardMinWidth: null,
715+
},
714716
};
715717
}),
716718
on(

tensorboard/webapp/metrics/store/metrics_reducers_test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,9 +1201,7 @@ describe('metrics reducers', () => {
12011201
});
12021202
const nextState = reducers(prevState, actions.metricsResetCardWidth());
12031203
expect(nextState.settings.cardMinWidth).toBe(400);
1204-
expect(nextState.settingOverrides.hasOwnProperty('cardMinWidth')).toBe(
1205-
false
1206-
);
1204+
expect(nextState.settingOverrides.cardMinWidth).toBeNull();
12071205
});
12081206
});
12091207

0 commit comments

Comments
 (0)