fix purpose dropdown

This commit is contained in:
Niqui O'Neill 2020-11-30 14:21:35 -08:00
parent 71aa9c128e
commit e1276a60e1
2 changed files with 11 additions and 11 deletions

View File

@ -35,8 +35,7 @@ const CommentWidget = props => {
// Last draft comment without a creator field goes into the reply field // Last draft comment without a creator field goes into the reply field
const draftReply = getDraftReply(all.slice().reverse().find(b => b.draft && !b.creator), all.length > 1); const draftReply = getDraftReply(all.slice().reverse().find(b => b.draft && !b.creator), all.length > 1);
// All except draft reply // All except draft reply
let comments = all.filter(b => b != draftReply); const comments = all.filter(b => b != draftReply);
comments = comments.map(elem => getDraftReply(elem));
const onEditReply = evt => { const onEditReply = evt => {
const prev = draftReply.value; const prev = draftReply.value;
const updated = evt.target.value; const updated = evt.target.value;
@ -55,7 +54,6 @@ const CommentWidget = props => {
const updated = evt.value.trim(); const updated = evt.value.trim();
if (draftReply.value == '' && updated.length > 0) { if (draftReply.value == '' && updated.length > 0) {
draftReply.purpose = updated; draftReply.purpose = updated;
this.setState({purpose: updated});
} else { } else {
props.onUpdateBody(draftReply, { ...draftReply, purpose: updated }); props.onUpdateBody(draftReply, { ...draftReply, purpose: updated });
} }
@ -109,12 +107,12 @@ const CommentWidget = props => {
onChange={onEditReply} onChange={onEditReply}
onSaveAndClose={() => props.onSaveAndClose()} onSaveAndClose={() => props.onSaveAndClose()}
/> />
{ props.purpose == true && { props.purpose == true && draftReply.value.length > 0 &&
<TypeDropdown <TypeDropdown
editable={true} editable={true}
content={draftReply.purpose} content={draftReply.purpose}
onChange={onUpdatePurpose} onChange={onUpdatePurpose}
onSaveAndClose={props.onSaveAndClose} onSaveAndClose={() => props.onSaveAndClose()}
/> />
} }
</div> </div>

View File

@ -8,12 +8,14 @@ export default class TypeDropdown extends Component {
render() { render() {
const selectedOption = this.props.content ? {'value': this.props.content, 'label': this.props.content.charAt(0).toUpperCase() + this.props.content.slice(1) } : undefined; const selectedOption = this.props.content ? {'value': this.props.content, 'label': this.props.content.charAt(0).toUpperCase() + this.props.content.slice(1) } : undefined;
return ( return (
<Select <div class="purposedropdown">
value={selectedOption} <Select
onChange={this.props.onChange} value={selectedOption}
options={purposes} onChange={this.props.onChange}
isDisabled={!this.props.editable} options={purposes}
/> isDisabled={!this.props.editable}
/>
</div>
); );
} }
} }