Various minor upload description fixes

main
Thibaut Girka 6 years ago committed by ThibG
parent 534439e73b
commit 7423c0c130

@ -41,11 +41,10 @@ const handlers = {
onChangeDescription, onChangeDescription,
} = this.props; } = this.props;
const { dirtyDescription } = this.state; const { dirtyDescription } = this.state;
this.setState({ dirtyDescription: null, focused: false });
if (id && onChangeDescription && dirtyDescription !== null) { if (id && onChangeDescription && dirtyDescription !== null) {
this.setState({
dirtyDescription: null,
focused: false,
});
onChangeDescription(id, dirtyDescription); onChangeDescription(id, dirtyDescription);
} }
}, },
@ -120,7 +119,6 @@ export default class ComposerUploadFormItem extends React.PureComponent {
handleFocalPointClick, handleFocalPointClick,
} = this.handlers; } = this.handlers;
const { const {
description,
intl, intl,
preview, preview,
focusX, focusX,
@ -132,9 +130,11 @@ export default class ComposerUploadFormItem extends React.PureComponent {
hovered, hovered,
dirtyDescription, dirtyDescription,
} = this.state; } = 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 x = ((focusX / 2) + .5) * 100;
const y = ((focusY / -2) + .5) * 100; const y = ((focusY / -2) + .5) * 100;
const description = dirtyDescription || (dirtyDescription !== '' && this.props.description) || '';
// The result. // The result.
return ( return (
@ -160,7 +160,7 @@ export default class ComposerUploadFormItem extends React.PureComponent {
backgroundPosition: `${x}% ${y}%` 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}> <button className='icon-button' onClick={handleRemove}>
<i className='fa fa-times' /> <FormattedMessage {...messages.undo} /> <i className='fa fa-times' /> <FormattedMessage {...messages.undo} />
</button> </button>
@ -175,7 +175,7 @@ export default class ComposerUploadFormItem extends React.PureComponent {
onFocus={handleFocus} onFocus={handleFocus}
placeholder={intl.formatMessage(messages.description)} placeholder={intl.formatMessage(messages.description)}
type='text' type='text'
value={dirtyDescription || description || ''} value={description}
/> />
</label> </label>
</div> </div>

Loading…
Cancel
Save