react-d3-tree icon indicating copy to clipboard operation
react-d3-tree copied to clipboard

<foreignObject> doesn't seem to have the same result in Safari/Firefox as it does in Chrome browsers

Open francisngo opened this issue 4 years ago • 4 comments

For foreignObject in Safari browsers, nodes are given additional width and height and the tree links are not positioned in the correct place as they are in Chrome browsers. Similar with Firefox, styling from foreignObjectWrappers are not applied.

Are you reporting a bug, or opening a feature request?

Bug

What is the actual behavior/output?

foreignObject's width/height and positions in Safari are not equal to Chrome.

What is the behavior/output you expect?

foreignObject's and tree link's positions are off and not accurate.

Can you consistently reproduce the issue/create a reproduction case (e.g. on https://codesandbox.io)?

View link in chrome then in safari and firefox to see the difference: https://codesandbox.io/s/0362k66m0n

What version of react-d3-tree are you using?

latest version

francisngo avatar Jul 10 '19 22:07 francisngo

For Safari Browsers, I found out that in ForeignObjectElement.jsx, the width and height set in <foreignObject width={nodeSize.x - BASE_MARGIN} height={nodeSize.y - BASE_MARGIN} {...foreignObjectWrapper} /> overwrites the prop's foreignObjectWrapper.style.width and ...height. Is there a way to override the width and height set in <foreignObject> for safari browsers to use the one from props?

francisngo avatar Jul 11 '19 17:07 francisngo

For Safari Browsers, I found out that in ForeignObjectElement.jsx, the width and height set in <foreignObject width={nodeSize.x - BASE_MARGIN} height={nodeSize.y - BASE_MARGIN} {...foreignObjectWrapper} /> overwrites the prop's foreignObjectWrapper.style.width and ...height. Is there a way to override the width and height set in <foreignObject> for safari browsers to use the one from props?

@francisngo Have you fixed this issue

Nilanth avatar Aug 30 '19 10:08 Nilanth

For Safari Browsers, I found out that in ForeignObjectElement.jsx, the width and height set in <foreignObject width={nodeSize.x - BASE_MARGIN} height={nodeSize.y - BASE_MARGIN} {...foreignObjectWrapper} /> overwrites the prop's foreignObjectWrapper.style.width and ...height.

Ah man, sorry about this (and my very delayed response); I had no idea that the way that expression evaluates would be subject to browser compat :/

I'm currently cleaning up the repo & committing myself to shipping a v2 in the coming weeks, which I will make this a part of, since I think the wisest move here is to remove that implicit base margin (breaking change -> v2) which is confusing anyways.

Thank you for reporting this issue, I'll update here when it's fixed!

bkrem avatar Jan 15 '20 16:01 bkrem

Please note that #284 may be related to this. I'm still going to remove the base margins for v2, but if you're seeing odd behaviour in Safari it may also be related to this upstream issue in the browser itself.

Will report back here once I've done my own investigation into cross-browser issues in v1 and how they can (hopefully) be mitigated for v2.

bkrem avatar Mar 15 '20 10:03 bkrem