From commits-return-1862-archive-asf-public=cust-asf.ponee.io@superset.incubator.apache.org Mon Nov 19 23:02:14 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 4A5CB180671 for ; Mon, 19 Nov 2018 23:02:14 +0100 (CET) Received: (qmail 53320 invoked by uid 500); 19 Nov 2018 22:02:13 -0000 Mailing-List: contact commits-help@superset.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.incubator.apache.org Delivered-To: mailing list commits@superset.incubator.apache.org Received: (qmail 53311 invoked by uid 99); 19 Nov 2018 22:02:13 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Nov 2018 22:02:13 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id B3368850D1; Mon, 19 Nov 2018 22:02:12 +0000 (UTC) Date: Mon, 19 Nov 2018 22:02:12 +0000 To: "commits@superset.apache.org" Subject: [incubator-superset] branch master updated: [bugfix] deckgl legend is not interactive (#6365) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154266493243.2531.9053556685626443031@gitbox.apache.org> From: maximebeauchemin@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-superset X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 4c4b6c41a1ee0c2f4172208389b616d666b0ea1d X-Git-Newrev: 8155f4bf30ebd94eab96a85f625f94cb9c517679 X-Git-Rev: 8155f4bf30ebd94eab96a85f625f94cb9c517679 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. maximebeauchemin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git The following commit(s) were added to refs/heads/master by this push: new 8155f4b [bugfix] deckgl legend is not interactive (#6365) 8155f4b is described below commit 8155f4bf30ebd94eab96a85f625f94cb9c517679 Author: Maxime Beauchemin AuthorDate: Mon Nov 19 14:02:07 2018 -0800 [bugfix] deckgl legend is not interactive (#6365) * [bugfix] deckgl legend is not interactive Somehow when clicking categories in the legend, nothing happened. The problem seemed to be around the `getDerivedStateFromProps` override which gets triggered after each render and would alter the state and reset the categories state to their origin. Changed the method name to not be an override and just be called once in the constructor https://reactjs.org/docs/react-component.html#static-getderivedstatefromprops * lint --- .../deckgl/CategoricalDeckGLContainer.jsx | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/superset/assets/src/visualizations/deckgl/CategoricalDeckGLContainer.jsx b/superset/assets/src/visualizations/deckgl/CategoricalDeckGLContainer.jsx index c3b9ccc..dd88f70 100644 --- a/superset/assets/src/visualizations/deckgl/CategoricalDeckGLContainer.jsx +++ b/superset/assets/src/visualizations/deckgl/CategoricalDeckGLContainer.jsx @@ -52,8 +52,7 @@ export default class CategoricalDeckGLContainer extends React.PureComponent { */ constructor(props) { super(props); - - this.state = CategoricalDeckGLContainer.getDerivedStateFromProps(props); + this.state = this.getInitialStateFromProps(props); this.getLayers = this.getLayers.bind(this); this.onValuesChange = this.onValuesChange.bind(this); @@ -61,7 +60,17 @@ export default class CategoricalDeckGLContainer extends React.PureComponent { this.toggleCategory = this.toggleCategory.bind(this); this.showSingleCategory = this.showSingleCategory.bind(this); } - static getDerivedStateFromProps(props, state) { + onValuesChange(values) { + this.setState({ + values: Array.isArray(values) + ? values + : [values, values + this.state.getStep(values)], + }); + } + onViewportChange(viewport) { + this.setState({ viewport }); + } + getInitialStateFromProps(props, state) { const features = props.payload.data.features || []; const timestamps = features.map(f => f.__timestamp); const categories = getCategories(props.formData, features); @@ -106,16 +115,6 @@ export default class CategoricalDeckGLContainer extends React.PureComponent { categories, }; } - onValuesChange(values) { - this.setState({ - values: Array.isArray(values) - ? values - : [values, values + this.state.getStep(values)], - }); - } - onViewportChange(viewport) { - this.setState({ viewport }); - } getLayers(values) { const { getLayer, @@ -171,15 +170,19 @@ export default class CategoricalDeckGLContainer extends React.PureComponent { } toggleCategory(category) { const categoryState = this.state.categories[category]; - categoryState.enabled = !categoryState.enabled; - const categories = { ...this.state.categories, [category]: categoryState }; + const categories = { + ...this.state.categories, + [category]: { + ...categoryState, + enabled: !categoryState.enabled, + }, + }; // if all categories are disabled, enable all -- similar to nvd3 if (Object.values(categories).every(v => !v.enabled)) { /* eslint-disable no-param-reassign */ Object.values(categories).forEach((v) => { v.enabled = true; }); } - this.setState({ categories }); } showSingleCategory(category) {