about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-08-18 14:53:25 +0200
committerThibG <thib@sitedethib.com>2018-08-18 17:53:20 +0200
commit7423c0c1308555db3072ae64141250fdd33ce235 (patch)
tree48225103eaef5d336935a088ae41568ed8e8193f
parent534439e73b95814b0db927052c9522c60fc306c5 (diff)
Various minor upload description fixes
-rw-r--r--app/javascript/flavours/glitch/features/composer/upload_form/item/index.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/javascript/flavours/glitch/features/composer/upload_form/item/index.js b/app/javascript/flavours/glitch/features/composer/upload_form/item/index.js
index b9986588f..5addccfb1 100644
--- a/app/javascript/flavours/glitch/features/composer/upload_form/item/index.js
+++ b/app/javascript/flavours/glitch/features/composer/upload_form/item/index.js
@@ -41,11 +41,10 @@ const handlers = {
       onChangeDescription,
     } = this.props;
     const { dirtyDescription } = this.state;
+
+    this.setState({ dirtyDescription: null, focused: false });
+
     if (id && onChangeDescription && dirtyDescription !== null) {
-      this.setState({
-        dirtyDescription: null,
-        focused: false,
-      });
       onChangeDescription(id, dirtyDescription);
     }
   },
@@ -120,7 +119,6 @@ export default class ComposerUploadFormItem extends React.PureComponent {
       handleFocalPointClick,
     } = this.handlers;
     const {
-      description,
       intl,
       preview,
       focusX,
@@ -132,9 +130,11 @@ export default class ComposerUploadFormItem extends React.PureComponent {
       hovered,
       dirtyDescription,
     } = this.state;
-    const computedClass = classNames('composer--upload_form--item', { active: hovered || focused });
+    const active = hovered || focused;
+    const computedClass = classNames('composer--upload_form--item', { active });
     const x = ((focusX /  2) + .5) * 100;
     const y = ((focusY / -2) + .5) * 100;
+    const description = dirtyDescription || (dirtyDescription !== '' && this.props.description) || '';
 
     //  The result.
     return (
@@ -160,7 +160,7 @@ export default class ComposerUploadFormItem extends React.PureComponent {
                 backgroundPosition: `${x}% ${y}%`
               }}
             >
-              <div className={classNames('composer--upload_form--actions', { active: hovered || focused })}>
+              <div className={classNames('composer--upload_form--actions', { active })}>
                 <button className='icon-button' onClick={handleRemove}>
                   <i className='fa fa-times' /> <FormattedMessage {...messages.undo} />
                 </button>
@@ -175,7 +175,7 @@ export default class ComposerUploadFormItem extends React.PureComponent {
                   onFocus={handleFocus}
                   placeholder={intl.formatMessage(messages.description)}
                   type='text'
-                  value={dirtyDescription || description || ''}
+                  value={description}
                 />
               </label>
             </div>