Skip to content

Commit 5aae7b0

Browse files
committed
better placeholders
1 parent 5035673 commit 5aae7b0

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/components/incubator/EditingOverviewCard.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ export class EditingOverviewCard extends React.Component<Props, IState> {
5959
};
6060

6161
private toggleEditField = (field: keyof IAssessmentOverview) => (e: any) => {
62-
this.setState({
63-
editingOverviewField: field,
64-
fieldValue: this.props.overview[field]
65-
});
62+
if (this.state.editingOverviewField !== field) {
63+
this.setState({
64+
editingOverviewField: field,
65+
fieldValue: this.props.overview[field]
66+
});
67+
}
6668
};
6769

6870
private handleExportXml = () => (e: any) => {
@@ -161,7 +163,7 @@ export class EditingOverviewCard extends React.Component<Props, IState> {
161163
}
162164

163165
const createPlaceholder = (str: string): string => {
164-
if (str.match('^\n*$')) {
166+
if (str.match('^(\n| )*$')) {
165167
return 'Enter Value Here.';
166168
} else {
167169
return str;

src/components/incubator/editingWorkspaceSideContent/TextareaContent.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ export class TextareaContent extends React.Component<IProps, IState> {
4040
if (this.state.isEditing) {
4141
display = <div onClick={this.toggleEditField()}>{this.makeEditingTextarea()}</div>;
4242
} else {
43-
const value = getValueFromPath(this.props.path, this.props.assessment);
43+
let value = getValueFromPath(this.props.path, this.props.assessment) || filler;
44+
value = value.match('^(\n| )*$') ? filler : value;
4445
display = (
4546
<div onClick={this.toggleEditField()}>
46-
{this.state.useRawValue ? value : <Markdown content={value || filler} />}
47+
{this.state.useRawValue ? value : <Markdown content={value} />}
4748
</div>
4849
);
4950
}
@@ -95,11 +96,13 @@ export class TextareaContent extends React.Component<IProps, IState> {
9596
);
9697

9798
private toggleEditField = () => (e: any) => {
98-
const fieldVal = getValueFromPath(this.props.path, this.props.assessment) || '';
99-
this.setState({
100-
isEditing: true,
101-
fieldValue: typeof fieldVal === 'string' ? fieldVal : fieldVal.toString()
102-
});
99+
if (!this.state.isEditing) {
100+
const fieldVal = getValueFromPath(this.props.path, this.props.assessment) || '';
101+
this.setState({
102+
isEditing: true,
103+
fieldValue: typeof fieldVal === 'string' ? fieldVal : fieldVal.toString()
104+
});
105+
}
103106
};
104107
}
105108

0 commit comments

Comments
 (0)