You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2020/11/19 17:55:43 UTC
[incubator-superset] 01/02: [fix] handle null value in date filter
(#11655)
This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch test-email-profile
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit efd045c7c058c80e19e8e40f8c7f1da518f5691a
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Wed Nov 11 09:32:26 2020 -0800
[fix] handle null value in date filter (#11655)
(cherry picked from commit a9f9c4bbd548017cc96a59e2dd4cc0c526783c49)
---
.../explore/components/DateFilterControl_spec.jsx | 13 +++++++++++++
.../src/explore/components/controls/DateFilterControl.jsx | 4 ++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/spec/javascripts/explore/components/DateFilterControl_spec.jsx b/superset-frontend/spec/javascripts/explore/components/DateFilterControl_spec.jsx
index 49ac950..1a56b50 100644
--- a/superset-frontend/spec/javascripts/explore/components/DateFilterControl_spec.jsx
+++ b/superset-frontend/spec/javascripts/explore/components/DateFilterControl_spec.jsx
@@ -81,6 +81,19 @@ describe('DateFilterControl', () => {
expect(close).toBeCalled();
});
+ it('should handle null value', () => {
+ const open = jest.fn();
+ const close = jest.fn();
+ const props = {
+ ...defaultProps,
+ value: null,
+ onOpenDateFilterControl: open,
+ onCloseDateFilterControl: close,
+ };
+
+ expect(mount(<DateFilterControl {...props} />)).toExist();
+ });
+
it('renders two tabs in popover', () => {
const popoverContent = wrapper.find(Popover).first().props().content;
const popoverContentWrapper = mount(popoverContent);
diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl.jsx b/superset-frontend/src/explore/components/controls/DateFilterControl.jsx
index 70dc0db..c951bd1 100644
--- a/superset-frontend/src/explore/components/controls/DateFilterControl.jsx
+++ b/superset-frontend/src/explore/components/controls/DateFilterControl.jsx
@@ -236,11 +236,11 @@ class DateFilterControl extends React.Component {
};
const { value } = props;
- if (value.indexOf(SEPARATOR) >= 0) {
+ if (value && value.indexOf(SEPARATOR) >= 0) {
this.state = { ...this.state, ...getStateFromSeparator(value) };
} else if (COMMON_TIME_FRAMES.indexOf(value) >= 0) {
this.state = { ...this.state, ...getStateFromCommonTimeFrame(value) };
- } else {
+ } else if (value) {
this.state = { ...this.state, ...getStateFromCustomRange(value) };
}