mirror of
https://github.com/apache/superset.git
synced 2026-04-24 02:25:13 +00:00
[sqllab] fix data grid's instant search function (#4717)
* [sqllab] fix data grid's instant search function It looks like any non-string type would break the search feature. of `FilterableTable` * Addressing comments
This commit is contained in:
committed by
GitHub
parent
b3442a7b53
commit
069d61c53f
@@ -1,9 +1,12 @@
|
||||
export function getTextWidth(text, fontDetails = '12px Roboto') {
|
||||
const canvas = document.createElement('canvas');
|
||||
const context = canvas.getContext('2d');
|
||||
context.font = fontDetails;
|
||||
const metrics = context.measureText(text);
|
||||
return metrics.width;
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user