Skip to content

Commit 556e0d5

Browse files
fix: trigger change if default is {{now}} (#7272)
1 parent 64d91b8 commit 556e0d5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/decap-cms-widget-datetime/src/DateTimeControl.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ class DateTimeControl extends React.Component {
6262
isDisabled: false,
6363
};
6464

65+
componentDidMount() {
66+
const { value } = this.props;
67+
if (value === '{{now}}') {
68+
this.handleChange(this.getNow());
69+
}
70+
}
71+
6572
isUtc = this.props.field.get('picker_utc') || false;
6673

6774
escapeZ(str) {
@@ -123,10 +130,6 @@ class DateTimeControl extends React.Component {
123130
if (value === '') return value;
124131
const { format, inputFormat } = this.getFormat();
125132

126-
if (typeof value === 'string' && value?.replace(/\s+/g, '') === '{{now}}') {
127-
return this.getNow();
128-
}
129-
130133
const inputValue = this.isUtc
131134
? dayjs.utc(value, format).format(inputFormat)
132135
: dayjs(value, format).format(inputFormat);

0 commit comments

Comments
 (0)