betodealmeida commented on a change in pull request #7772: Reuse SVG node
URL: 
https://github.com/apache/incubator-superset/pull/7772#discussion_r297477654
 
 

 ##########
 File path: superset/assets/src/components/FilterableTable/FilterableTable.jsx
 ##########
 @@ -29,16 +29,18 @@ import {
   SortIndicator,
   Table,
 } from 'react-virtualized';
-import { getTextDimension } from '@superset-ui/dimension';
+import { createSVGNode, getTextDimension } from '@superset-ui/dimension';
 import { t } from '@superset-ui/translation';
 
 import Button from '../Button';
 import CopyToClipboard from '../CopyToClipboard';
 import ModalTrigger from '../ModalTrigger';
 import TooltipWrapper from '../TooltipWrapper';
 
+const svg = createSVGNode({ container: document.body });
+
 function getTextWidth(text, font = '12px Roboto') {
-  return getTextDimension({ text, style: { font } }).width;
+  return getTextDimension({ text, style: { font }, existingSVGNode: svg 
}).width;
 
 Review comment:
   Ah, you're right. I need to pass `font` when creating the SVG node.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to