Skip to content

Commit

Permalink
fix(explore): ignore temporary controls in altered pill (apache#19843)
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro authored and philipher29 committed Jun 9, 2022
1 parent b79f1b5 commit 635938e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ describe('AlteredSliceTag', () => {
expect(wrapper.instance().render()).toBeNull();
});

it('does not run when temporary controls have changes', () => {
props = {
origFormData: { ...props.origFormData, url_params: { foo: 'foo' } },
currentFormData: { ...props.origFormData, url_params: { bar: 'bar' } },
};
wrapper = mount(<AlteredSliceTag {...props} />);
expect(wrapper.instance().state.rows).toEqual([]);
expect(wrapper.instance().state.hasDiffs).toBe(false);
expect(wrapper.instance().render()).toBeNull();
});

it('sets new rows when receiving new props', () => {
const testRows = ['testValue'];
const getRowsFromDiffsStub = jest
Expand Down
5 changes: 3 additions & 2 deletions superset-frontend/src/components/AlteredSliceTag/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { isEmpty, isEqual } from 'lodash';
import { t } from '@superset-ui/core';
import { sanitizeFormData } from 'src/explore/exploreUtils/formData';
import getControlsForVizType from 'src/utils/getControlsForVizType';
import { safeStringify } from 'src/utils/safeStringify';
import { Tooltip } from 'src/components/Tooltip';
Expand Down Expand Up @@ -82,8 +83,8 @@ export default class AlteredSliceTag extends React.Component {
getDiffs(props) {
// Returns all properties that differ in the
// current form data and the saved form data
const ofd = props.origFormData;
const cfd = props.currentFormData;
const ofd = sanitizeFormData(props.origFormData);
const cfd = sanitizeFormData(props.currentFormData);

const fdKeys = Object.keys(cfd);
const diffs = {};
Expand Down

0 comments on commit 635938e

Please sign in to comment.