Skip to content

Commit db849de

Browse files
groupBy variable update logic cleaup (#1380)
1 parent bd10575 commit db849de

File tree

2 files changed

+0
-70
lines changed

2 files changed

+0
-70
lines changed

packages/scenes/src/variables/groupby/GroupByVariable.test.tsx

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -301,64 +301,6 @@ describe.each(['11.1.2', '11.1.1'])('GroupByVariable', (v) => {
301301
expect(variable.state.value).toEqual(['defaultVal1', 'defaultVal2']);
302302
});
303303

304-
it('should apply defaultValue to value when defaultValue is set', async () => {
305-
const { variable } = setupTest({});
306-
307-
expect(variable.state.value).toEqual('');
308-
309-
act(() => {
310-
variable.setState({
311-
defaultValue: {
312-
value: ['newDefault'],
313-
text: ['newDefault'],
314-
},
315-
});
316-
});
317-
318-
expect(variable.state.value).toEqual(['newDefault']);
319-
expect(variable.state.text).toEqual(['newDefault']);
320-
});
321-
322-
it('should update value when defaultValue changes', async () => {
323-
const { variable } = setupTest({
324-
defaultValue: {
325-
value: ['defaultVal1'],
326-
text: ['defaultVal1'],
327-
},
328-
});
329-
330-
expect(variable.state.value).toEqual(['defaultVal1']);
331-
332-
act(() => {
333-
variable.setState({
334-
defaultValue: {
335-
value: ['newDefault'],
336-
text: ['newDefault'],
337-
},
338-
});
339-
});
340-
341-
expect(variable.state.value).toEqual(['newDefault']);
342-
expect(variable.state.text).toEqual(['newDefault']);
343-
});
344-
345-
it('should reset value when defaultValue is cleared', async () => {
346-
const { variable } = setupTest({
347-
defaultValue: {
348-
value: ['defaultVal1'],
349-
text: ['defaultVal1'],
350-
},
351-
});
352-
353-
expect(variable.state.value).toEqual(['defaultVal1']);
354-
355-
act(() => {
356-
variable.setState({ defaultValue: undefined });
357-
});
358-
359-
expect(variable.state.value).toEqual([]);
360-
});
361-
362304
it('should work with browser history action on user action', () => {
363305
const { variable } = setupTest({
364306
defaultOptions: [

packages/scenes/src/variables/groupby/GroupByVariable.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,7 @@ export class GroupByVariable extends MultiValueVariable<GroupByVariableState> {
228228
}
229229
}
230230

231-
const sub = this.subscribeToState((newState, prevState) => {
232-
if (!isEqual(newState.defaultValue, prevState.defaultValue)) {
233-
if (newState.defaultValue) {
234-
this.changeValueTo(newState.defaultValue.value, newState.defaultValue.text, false);
235-
} else {
236-
this.changeValueTo([], [], false);
237-
}
238-
}
239-
});
240-
241231
return () => {
242-
sub.unsubscribe();
243-
244232
if (this.state.defaultValue) {
245233
this.restoreDefaultValues();
246234
}

0 commit comments

Comments
 (0)