-
Notifications
You must be signed in to change notification settings - Fork 77
Conversation
`jquery.datatables` will manipulate DOMs, sometimes remove them. In case of component being reloaded with updated props, React will not be able to find those removed nodes, causing a `cannot removeChild` error. Because of the the way to assign row keys, if table shape changes (add or remove columns), React may also have difficulty match the cached nodes via keys. In general it's a bad idea to directly manipulate React rendered DOM nodes, so we better just let `jquery.datatables` handle everything. In the future, once we removed `jquery.datatables`, a pure React component will not have such issues.
Deploy preview for superset-ui-plugins ready! Built with commit b7596d0 |
Can't wait to get rid of |
I don't think so. |
bb38eaf
to
0e95808
Compare
Codecov Report
@@ Coverage Diff @@
## master #392 +/- ##
========================================
+ Coverage 1.48% 2.78% +1.3%
========================================
Files 185 186 +1
Lines 5805 5812 +7
Branches 370 372 +2
========================================
+ Hits 86 162 +76
+ Misses 5707 5623 -84
- Partials 12 27 +15
Continue to review full report at Codecov.
|
packages/superset-ui-legacy-plugin-chart-table/test/test_data.ts
Outdated
Show resolved
Hide resolved
import { mount } from 'enzyme'; | ||
import ReactDataTable from '../src/ReactDataTable'; | ||
import transformProps from '../src/transformProps'; | ||
import * as testData from './test_data'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use specific import to enable warning if we later do not use some of these.
import { basic, advance } from ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to have a namespace so it's more explicit in later code, but also wanted to keep variable names simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a default export for testData
. I think it looks better than import *
.
In the future, maybe all plugins can reuse the same test data---similar to switching visualization type in Superset.
packages/superset-ui-legacy-plugin-chart-table/test/ReactDataTable.test.tsx
Outdated
Show resolved
Hide resolved
d1d76c9
to
c8a58c9
Compare
Not seeing the console.warn errors anymore. So cleaning it up. Previously it was from `<SuperChart />` component, but since we have updated the test case to not use <SuperChart>, we are good now.
This fixes bugs related to chart rerendering. apache-superset/superset-ui-plugins#392
This fixes bugs related to chart rerendering. apache-superset/superset-ui-plugins#392
* fix(legacy-table): avoid React DOM `jquery.datatables` will manipulate DOMs, sometimes remove them. In case of component being reloaded with updated props, React will not be able to find those removed nodes, causing a `cannot removeChild` error. Because of the the way to assign row keys, if table shape changes (add or remove columns), React may also have difficulty match the cached nodes via keys. In general it's a bad idea to directly manipulate React rendered DOM nodes, so we better just let `jquery.datatables` handle everything. In the future, once we removed `jquery.datatables`, a pure React component will not have such issues. * fix(legacy-table): handle the case when percentMetrics is null * fix(legacy-table): linting errors * refactor: use nimbus build * test(legacy-table): add React component tests * test(legacy-table): more sophisticated cases * fix: address PR apache-superset#392 comments * chore(legacy-table): clean up tests case setups Not seeing the console.warn errors anymore. So cleaning it up. Previously it was from `<SuperChart />` component, but since we have updated the test case to not use <SuperChart>, we are good now. * fix(legacy-table): misleading comment
* fix(legacy-table): avoid React DOM `jquery.datatables` will manipulate DOMs, sometimes remove them. In case of component being reloaded with updated props, React will not be able to find those removed nodes, causing a `cannot removeChild` error. Because of the the way to assign row keys, if table shape changes (add or remove columns), React may also have difficulty match the cached nodes via keys. In general it's a bad idea to directly manipulate React rendered DOM nodes, so we better just let `jquery.datatables` handle everything. In the future, once we removed `jquery.datatables`, a pure React component will not have such issues. * fix(legacy-table): handle the case when percentMetrics is null * fix(legacy-table): linting errors * refactor: use nimbus build * test(legacy-table): add React component tests * test(legacy-table): more sophisticated cases * fix: address PR apache-superset#392 comments * chore(legacy-table): clean up tests case setups Not seeing the console.warn errors anymore. So cleaning it up. Previously it was from `<SuperChart />` component, but since we have updated the test case to not use <SuperChart>, we are good now. * fix(legacy-table): misleading comment
jquery.datatables
will manipulate DOMs, sometimes remove them. In case of component being reloaded with updated props, React will not be able to find those removed nodes, causing acannot removeChild
error.Because of the the way to assign row keys, if table shape changes (add or remove columns), React may also have difficulty match the cached nodes via keys.
In general it's a bad idea to directly manipulate React rendered DOM nodes, so we better just let
jquery.datatables
handle everything.In the future, once we removed
jquery.datatables
, a pure React component will not have such issues.This PR also contains a fix to null
percent_metrics
.cc @kristw @etr2460
🐛 Bug Fix