fix editing visuals on groupview header

This commit is contained in:
Matthew Hodgson 2017-10-18 17:32:46 +01:00
parent 9160b70e12
commit 1087b36597

View file

@ -490,15 +490,15 @@ export default React.createClass({
}); });
}, },
_onNameChange: function(e) { _onNameChange: function(value) {
const newProfileForm = Object.assign(this.state.profileForm, { name: e.target.value }); const newProfileForm = Object.assign(this.state.profileForm, { name: value });
this.setState({ this.setState({
profileForm: newProfileForm, profileForm: newProfileForm,
}); });
}, },
_onShortDescChange: function(e) { _onShortDescChange: function(value) {
const newProfileForm = Object.assign(this.state.profileForm, { short_description: e.target.value }); const newProfileForm = Object.assign(this.state.profileForm, { short_description: value });
this.setState({ this.setState({
profileForm: newProfileForm, profileForm: newProfileForm,
}); });
@ -878,18 +878,29 @@ export default React.createClass({
</div> </div>
</div> </div>
); );
nameNode = <input type="text"
value={this.state.profileForm.name} const EditableText = sdk.getComponent("elements.EditableText");
onChange={this._onNameChange}
placeholder={_t('Group Name')} nameNode = <EditableText ref="nameEditor"
tabIndex="1" className="mx_GroupView_editable"
/>; placeholderClassName="mx_GroupView_placeholder"
shortDescNode = <input type="text" placeholder={_t("Group Name")}
value={this.state.profileForm.short_description} blurToCancel={false}
onChange={this._onShortDescChange} initialValue={this.state.profileForm.name}
placeholder={_t('Description')} onValueChanged={this._onNameChange}
tabIndex="2" tabIndex="1"
/>; dir="auto" />;
shortDescNode = <EditableText ref="descriptionEditor"
className="mx_GroupView_editable"
placeholderClassName="mx_GroupView_placeholder"
placeholder={_t("Description")}
blurToCancel={false}
initialValue={this.state.profileForm.short_description}
onValueChanged={this._onShortDescChange}
tabIndex="2"
dir="auto" />
rightButtons.push( rightButtons.push(
<AccessibleButton className="mx_GroupView_textButton mx_RoomHeader_textButton" <AccessibleButton className="mx_GroupView_textButton mx_RoomHeader_textButton"
onClick={this._onSaveClick} key="_saveButton" onClick={this._onSaveClick} key="_saveButton"
@ -911,17 +922,17 @@ export default React.createClass({
width={48} height={48} width={48} height={48}
/>; />;
if (summary.profile && summary.profile.name) { if (summary.profile && summary.profile.name) {
nameNode = <div> nameNode = <div onClick={this._onEditClick}>
<span>{ summary.profile.name }</span> <span>{ summary.profile.name }</span>
<span className="mx_GroupView_header_groupid"> <span className="mx_GroupView_header_groupid">
({ this.props.groupId }) ({ this.props.groupId })
</span> </span>
</div>; </div>;
} else { } else {
nameNode = <span>{ this.props.groupId }</span>; nameNode = <span onClick={this._onEditClick}>{ this.props.groupId }</span>;
} }
if (summary.profile && summary.profile.short_description) { if (summary.profile && summary.profile.short_description) {
shortDescNode = <span>{ summary.profile.short_description }</span>; shortDescNode = <span onClick={this._onEditClick}>{ summary.profile.short_description }</span>;
} }
rightButtons.push( rightButtons.push(
<AccessibleButton className="mx_GroupHeader_button" <AccessibleButton className="mx_GroupHeader_button"