From c65452bb018f3b89110d1a8a40b23110a91a62f9 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 3 Aug 2019 09:41:45 -0700 Subject: [PATCH] Fixed: Edit path on series index resetting cursor to end on change --- frontend/src/Components/Form/PathInput.js | 32 +++++++++++++++------ frontend/src/Store/Actions/seriesActions.js | 2 +- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/frontend/src/Components/Form/PathInput.js b/frontend/src/Components/Form/PathInput.js index 2bc47e586..40c4840ba 100644 --- a/frontend/src/Components/Form/PathInput.js +++ b/frontend/src/Components/Form/PathInput.js @@ -18,10 +18,19 @@ class PathInput extends Component { this._node = document.getElementById('portal-root'); this.state = { + value: props.value, isFileBrowserModalOpen: false }; } + componentDidUpdate(prevProps) { + const { value } = this.props; + + if (prevProps.value !== value) { + this.setState({ value }); + } + } + // // Control @@ -51,11 +60,8 @@ class PathInput extends Component { // // Listeners - onInputChange = (event, { newValue }) => { - this.props.onChange({ - name: this.props.name, - value: newValue - }); + onInputChange = ({ value }) => { + this.setState({ value }); } onInputKeyDown = (event) => { @@ -77,6 +83,11 @@ class PathInput extends Component { } onInputBlur = () => { + this.props.onChange({ + name: this.props.name, + value: this.state.value + }); + this.props.onClearPaths(); } @@ -108,13 +119,18 @@ class PathInput extends Component { const { className, name, - value, paths, includeFiles, hasFileBrowser, onChange, ...otherProps } = this.props; + + const { + value, + isFileBrowserModalOpen + } = this.state; + return (
{ @@ -144,7 +160,7 @@ class PathInput extends Component { { return { - section: 'series', + section, ...payload }; });