Comments (7)
@adilapapaya Thanks man, seeing people do cool stuff with this library is what keeps me motivated :)
As far as I can tell this is basically a mutex-type problem where the onClick handler needs to block until the associated transition time has expired.
I took a shot at this a while ago and didn't quite get there, will give it another serious shot whenever I can commit time during the next week.
As mentioned before, if you feel you have a clean solution to this annoying issue feel free to explain here and/or open a PR and I'll do my best to support you!
cc @superdyzio
from react-d3-tree.
Fixed in v1.10.4 🎉
Thank you @nimitwalia89 for your fix suggestion 👏
With your suggestion I finally broke through some mental barriers that had built up and found a simple solution to the issue that is completely contained within one flag and Tree.handleNodeToggle()
.
Fix commit for those interested: e5cf741
If the bug is still reproducible in 1.10.4
please reopen this issue, otherwise if you find regressions due to this fix please open another issue.
But for now: good riddance to this shitty bug! 🐛 👋
from react-d3-tree.
+1!
from react-d3-tree.
Apologies that this hasn't been resolved yet, tried debugging this multiple times in my spare time but haven't been able to pin down the cause yet.
Tackling it again this week, but would love to hear any suggestions/advice you guys have + of course your own PRs to patch this are welcome anytime.
from react-d3-tree.
Still occurs on v1.9.2. @bkrem - Have you approached this again since your last comment?
from react-d3-tree.
@bkrem I wonder if you could get around this by adding a dbl click listener and setting that to do nothing.
(also, thanks for the awesome library!!) :)
from react-d3-tree.
@bkrem i kind of found a solution for it. Please give it a try.
Inside Tree/index.js add a variable outside class
let clickDisabled = false;
handleNodeToggle(nodeId, evt) {
const data = clone(this.state.data);
const matches = this.findNodesById(nodeId, data, []);
const targetNode = matches[0];
if (this.props.collapsible) {
if(!clickDisabled){
console.log('click');
targetNode._collapsed ? this.expandNode(targetNode) : this.collapseNode(targetNode);
this.setState({ data }, () => this.handleOnClickCb(targetNode, evt));
this.internalState.targetNode = targetNode;
}
} else {
this.handleOnClickCb(targetNode, evt);
}
}
testBreakFix = () => {
clickDisabled = !clickDisabled;
}
add clickToggle={this.testBreakFix}
prop to Link.
then inside Link/index.js
let timer = null; keep this outside class.
applyOpacity(opacity, transitionDuration, transitionComplete) {
this.props.clickToggle();
if (transitionDuration === 0) {
select(this.link).style('opacity', opacity);
this.transitionComplete();
} else {
select(this.link)
.transition()
.duration(transitionDuration)
.style('opacity', opacity)
.each('end', this.transitionComplete());
}
}
transitionComplete = () => {
clearTimeout(timer);
timer = setTimeout(this.timerFunc, this.props.transitionDuration + 100);
}
timerFunc = () => {
console.log('All done');
this.props.clickToggle();
}
Hope this helps
from react-d3-tree.
Related Issues (20)
- onNodeOver event works also onClick?
- how to style node elements using jsx
- Is it possible to add Scroll bars to view the chart?
- draggable prop issue HOT 3
- [question] Default tree is not centered and nodes are cut off HOT 1
- LeafNode still not targeted correctly HOT 1
- Is there a way to open previous node on route back to page having react-d3-tree.im routing user to next page from react d3tree.
- Is there a search option available to open d3tree and show ?
- Cannot find a declaration file for module HOT 3
- How to use non-copyable objects as data?
- Getting error: selection2.interrupt is not a function at zoom.transform
- How to center a node HOT 1
- Safari: foreignobject render issue HOT 2
- Zoom and Drag not working on NextJS HOT 2
- How to center a node on from external event
- Tree not centering when using renderCustomNodeElement prop
- This is having older version of "@bkrem/react-transition-group": "^1.3.3", in package.json.
- How to restrict the drag area?
- Intersection bug
- Codesandbox examples not available HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-d3-tree.