e.target.select()}
onClick={this.toggle.bind(this)}
diff --git a/src/components/FileEditor/FileEditor.react.js b/src/components/FileEditor/FileEditor.react.js
index 7e438a995a..5c2b507026 100644
--- a/src/components/FileEditor/FileEditor.react.js
+++ b/src/components/FileEditor/FileEditor.react.js
@@ -21,6 +21,8 @@ export default class FileEditor extends React.Component {
this.checkExternalClick = this.checkExternalClick.bind(this);
this.handleKey = this.handleKey.bind(this);
this.removeFile = this.removeFile.bind(this);
+ this.inputRef = React.createRef();
+ this.fileInputRef = React.createRef();
}
componentDidMount() {
@@ -31,7 +33,7 @@ export default class FileEditor extends React.Component {
fileInputElement.click();
}
}
-
+
componentWillUnmount() {
document.body.removeEventListener('click', this.checkExternalClick);
document.body.removeEventListener('keypress', this.handleKey);
@@ -39,7 +41,7 @@ export default class FileEditor extends React.Component {
checkExternalClick(e) {
const { onCancel } = this.props;
- if (!hasAncestor(e.target, this.refs.input) && onCancel) {
+ if (!hasAncestor(e.target, this.inputRef.current) && onCancel) {
onCancel();
}
}
@@ -61,7 +63,7 @@ export default class FileEditor extends React.Component {
}
removeFile() {
- this.refs.fileInput.value = '';
+ this.fileInputRef.current.value = '';
this.props.onCommit(undefined);
}
@@ -76,9 +78,9 @@ export default class FileEditor extends React.Component {
render() {
const file = this.props.value;
return (
-
+
diff --git a/src/components/GeoPointEditor/GeoPointEditor.react.js b/src/components/GeoPointEditor/GeoPointEditor.react.js
index a91c708cb5..597bc529ee 100644
--- a/src/components/GeoPointEditor/GeoPointEditor.react.js
+++ b/src/components/GeoPointEditor/GeoPointEditor.react.js
@@ -22,15 +22,18 @@ export default class GeoPointEditor extends React.Component {
this.checkExternalClick = this.checkExternalClick.bind(this);
this.handleKeyLatitude = this.handleKeyLatitude.bind(this);
this.handleKeyLongitude = this.handleKeyLongitude.bind(this);
+
+ this.latitudeRef = React.createRef();
+ this.longitudeRef = React.createRef();
}
componentDidMount() {
if (!this.props.disableAutoFocus) {
- this.refs.latitude.focus();
+ this.latitudeRef.current.focus();
}
- this.refs.latitude.setSelectionRange(0, String(this.state.latitude).length);
- this.refs.latitude.addEventListener('keypress', this.handleKeyLatitude);
- this.refs.longitude.addEventListener('keypress', this.handleKeyLongitude);
+ this.latitudeRef.current.setSelectionRange(0, String(this.state.latitude).length);
+ this.latitudeRef.current.addEventListener('keypress', this.handleKeyLatitude);
+ this.longitudeRef.current.addEventListener('keypress', this.handleKeyLongitude);
}
componentWillReceiveProps(props) {
@@ -45,8 +48,8 @@ export default class GeoPointEditor extends React.Component {
}
componentWillUnmount() {
- this.refs.latitude.removeEventListener('keypress', this.handleKeyLatitude);
- this.refs.longitude.removeEventListener('keypress', this.handleKeyLongitude);
+ this.latitudeRef.current.removeEventListener('keypress', this.handleKeyLatitude);
+ this.longitudeRef.current.removeEventListener('keypress', this.handleKeyLongitude);
}
checkExternalClick() {
@@ -55,8 +58,8 @@ export default class GeoPointEditor extends React.Component {
// check if activeElement is something else from input fields,
// to avoid commiting new value on every switch of focus beetween latitude and longitude fields
if (
- document.activeElement !== this.refs.latitude &&
- document.activeElement !== this.refs.longitude
+ document.activeElement !== this.latitudeRef.current &&
+ document.activeElement !== this.longitudeRef.current
) {
this.commitValue();
}
@@ -65,8 +68,8 @@ export default class GeoPointEditor extends React.Component {
handleKeyLatitude(e) {
if (e.keyCode === 13 || e.keyCode === 44) {
- this.refs.longitude.focus();
- this.refs.longitude.setSelectionRange(0, String(this.state.longitude).length);
+ this.longitudeRef.current.focus();
+ this.longitudeRef.current.setSelectionRange(0, String(this.state.longitude).length);
}
}
@@ -112,15 +115,15 @@ export default class GeoPointEditor extends React.Component {
if (values[1].length <= 0 || !validateNumeric(values[1])) {
this.setState({ latitude: values[0] });
- this.refs.longitude.focus();
- this.refs.longitude.setSelectionRange(0, String(this.state.longitude).length);
+ this.longitudeRef.current.focus();
+ this.longitudeRef.current.setSelectionRange(0, String(this.state.longitude).length);
return;
}
if (validateNumeric(values[1])) {
this.setState({ latitude: values[0] });
this.setState({ longitude: values[1] });
- this.refs.longitude.focus();
+ this.longitudeRef.current.focus();
return;
}
}
@@ -130,14 +133,14 @@ export default class GeoPointEditor extends React.Component {
this.setState({ [target]: validateNumeric(value) ? value : this.state[target] });
};
return (
-