Skip to content

Commit 4f34402

Browse files
committed
Reload codemirror when fonts are loaded
Signed-off-by: Maxim Sukharev <[email protected]>
1 parent b1e6499 commit 4f34402

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

frontend/src/components/QueryBox.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class QueryBox extends Component {
2222
schema: undefined,
2323
codeMirrorTables: {}
2424
};
25+
26+
this.codemirror = React.createRef();
2527
}
2628

2729
static getDerivedStateFromProps(nextProps, prevState) {
@@ -35,6 +37,18 @@ class QueryBox extends Component {
3537
};
3638
}
3739

40+
componentDidMount() {
41+
// IE or old browsers
42+
if (!document.fonts || !document.fonts.ready) {
43+
return;
44+
}
45+
46+
// we use custom font, codemirror needs refresh when the font is loaded
47+
document.fonts.ready.then(() => {
48+
this.codemirror.current.editor.refresh();
49+
});
50+
}
51+
3852
static schemaToCodeMirror(schema) {
3953
if (!schema) {
4054
return {};
@@ -85,6 +99,7 @@ class QueryBox extends Component {
8599
<Row className="codemirror-row no-spacing">
86100
<Col xs={12} className="codemirror-col no-spacing">
87101
<CodeMirror
102+
ref={this.codemirror}
88103
value={this.props.sql}
89104
options={options}
90105
onBeforeChange={(editor, data, value) => {

0 commit comments

Comments
 (0)