Make it run better in IE11

This commit is contained in:
Ken-Håvard Lieng 2018-05-06 21:36:05 +02:00
parent 91e5556c86
commit 29a225ed13
5 changed files with 48 additions and 21 deletions

View file

@ -33,7 +33,8 @@ export default class Editable extends PureComponent {
const padding =
parseInt(style.paddingLeft, 10) + parseInt(style.paddingRight, 10);
// Make sure the width is atleast 1px so the caret always shows
const width = stringWidth(value, style.font) || 1;
const width =
stringWidth(value, `${style.fontSize} ${style.fontFamily}`) || 1;
return padding + width;
}
}
@ -69,6 +70,12 @@ export default class Editable extends PureComponent {
}
};
handleFocus = e => {
const val = e.target.value;
e.target.value = '';
e.target.value = val;
};
inputRef = el => {
this.input = el;
};
@ -90,6 +97,7 @@ export default class Editable extends PureComponent {
onBlur={this.handleBlur}
onChange={this.handleChange}
onKeyDown={this.handleKey}
onFocus={this.handleFocus}
style={style}
spellCheck={false}
/>

View file

@ -1,4 +1,5 @@
import 'es6-promise/auto';
import 'utils/ie11';
import React from 'react';
import { render } from 'react-dom';

View file

@ -0,0 +1,12 @@
if (Object.keys) {
try {
Object.keys('');
} catch (e) {
Object.keys = function(o, k, r) {
r = [];
// eslint-disable-next-line
for (k in o) r.hasOwnProperty.call(o, k) && r.push(k);
return r;
};
}
}