mirror of
https://github.com/apache/superset.git
synced 2026-04-23 01:55:09 +00:00
* [sqllab] fix data grid's instant search function It looks like any non-string type would break the search feature. of `FilterableTable` * Addressing comments
15 lines
373 B
JavaScript
15 lines
373 B
JavaScript
export function getTextWidth(text, fontDetails = '12px Roboto') {
|
|
const canvas = document.createElement('canvas');
|
|
const context = canvas.getContext('2d');
|
|
if (context) {
|
|
// Won't work outside of a browser context (ie unit tests)
|
|
context.font = fontDetails;
|
|
return context.measureText(text).width;
|
|
}
|
|
return 100;
|
|
}
|
|
|
|
export default {
|
|
getTextWidth,
|
|
};
|