fix: allow widgets to control value to be validated (#3448)
This commit is contained in:
parent
228c6b41e2
commit
ae1917c818
@ -97,7 +97,7 @@ export default class Widget extends Component {
|
||||
};
|
||||
|
||||
validate = (skipWrapped = false) => {
|
||||
let value = this.props.value;
|
||||
let value = this.innerWrappedControl?.getValidateValue?.() || this.props.value;
|
||||
// Convert list input widget value to string for validation test
|
||||
List.isList(value) && (value = value.join(','));
|
||||
|
||||
|
@ -7,6 +7,7 @@ import { once } from 'lodash';
|
||||
import uuid from 'uuid/v4';
|
||||
import { oneLine } from 'common-tags';
|
||||
import { lengths, components, buttons, borders, effects, shadows } from 'netlify-cms-ui-default';
|
||||
import { basename } from 'netlify-cms-lib-util';
|
||||
|
||||
const MAX_DISPLAY_LENGTH = 50;
|
||||
|
||||
@ -175,6 +176,14 @@ export default function withFileControl({ forImage } = {}) {
|
||||
return this.props.onChange('');
|
||||
};
|
||||
|
||||
getValidateValue = () => {
|
||||
if (this.props.value) {
|
||||
return basename(this.props.value);
|
||||
}
|
||||
|
||||
return this.props.value;
|
||||
};
|
||||
|
||||
renderFileLink = value => {
|
||||
const size = MAX_DISPLAY_LENGTH;
|
||||
if (!value || value.length <= size) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user