diff --git a/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx b/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx index 5387c5e94..20edc28cd 100644 --- a/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx +++ b/superset-frontend/spec/javascripts/dashboard/components/PropertiesModal_spec.jsx @@ -113,7 +113,7 @@ describe('PropertiesModal', () => { const spy = jest.spyOn(modalInstance, 'onMetadataChange'); modalInstance.onColorSchemeChange('SUPERSET_DEFAULT'); expect(spy).toHaveBeenCalledWith( - '{"color_scheme": "SUPERSET_DEFAULT"}', + '{"color_scheme": "SUPERSET_DEFAULT", "label_colors": {}}', ); }); }); diff --git a/superset-frontend/src/dashboard/components/PropertiesModal.jsx b/superset-frontend/src/dashboard/components/PropertiesModal.jsx index 481893fb4..170d7871d 100644 --- a/superset-frontend/src/dashboard/components/PropertiesModal.jsx +++ b/superset-frontend/src/dashboard/components/PropertiesModal.jsx @@ -28,6 +28,7 @@ import { t, SupersetClient, getCategoricalSchemeRegistry, + CategoricalColorNamespace, } from '@superset-ui/core'; import Modal from 'src/common/components/Modal'; @@ -158,6 +159,15 @@ class PropertiesModal extends React.PureComponent { Object.keys(jsonMetadataObj).includes('color_scheme') ) { jsonMetadataObj.color_scheme = value; + jsonMetadataObj.label_colors = Object.keys( + jsonMetadataObj.label_colors ?? {}, + ).reduce( + (prev, next) => ({ + ...prev, + [next]: CategoricalColorNamespace.getScale(value)(next), + }), + {}, + ); this.onMetadataChange(jsonStringify(jsonMetadataObj)); }