From 5c2c07d163a61bc891250c6d21ea3ff545edd2b5 Mon Sep 17 00:00:00 2001 From: Jan Cerman Date: Fri, 19 Jun 2020 10:39:12 +0200 Subject: [PATCH] fix: do not display long regexps (#1295) --- src/components/Fields/FieldDetails.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Fields/FieldDetails.tsx b/src/components/Fields/FieldDetails.tsx index c3b8f26daf..5835e5bc10 100644 --- a/src/components/Fields/FieldDetails.tsx +++ b/src/components/Fields/FieldDetails.tsx @@ -21,8 +21,12 @@ import { FieldDetail } from './FieldDetail'; import { Badge } from '../../common-elements/'; import { l } from '../../services/Labels'; +import { OptionsContext } from '../OptionsProvider'; + +const MAX_PATTERN_LENGTH = 45; export class FieldDetails extends React.PureComponent { + static contextType = OptionsContext; render() { const { showExamples, field, renderDiscriminatorSwitch } = this.props; const { enumSkipQuotes } = this.context; @@ -58,7 +62,9 @@ export class FieldDetails extends React.PureComponent { {/*{schema.title && ({schema.title}) }*/} {schema.nullable && {l('nullable')} } - {schema.pattern && {schema.pattern} } + {schema.pattern && schema.pattern.length < MAX_PATTERN_LENGTH && ( + {schema.pattern} + )} {schema.isCircular && {l('recursive')} } {deprecated && (