Closed mrehder closed 5 years ago
@mrehder @schmunk42 @marc7000 @germanbisurgi I have pinpointed the problem to the "getDisplayText" function in "src/editor.js":
else if(JSON.stringify(el).length < 50) name = JSON.stringify(el);
else name = "type";
Doing a JSON.stringify on the el object with a pattern of 35 characters gives exactly the length 50. This also explains why the 2nd option gets the value "type".
I'm not sure why there is this 50 character limit (Don't want to change it if it breaks other functionality), but maybe someone can shed some light on this? (Changing the "50", to a higher value like "150", fixes the pattern problem)
If there are no objections, I'll go ahead and fix this by increasing the 50 value to 150.
I think the value could be even higher, like 500. I don't know about issues with large patterns.
CC: @marc7000 @jdorn
I agree is must be large. A regexp pattern for something like an ipv4/ipv6 address is quite large.
Thanks Mike
From: Tobias Munk [mailto:notifications@github.com] Sent: Monday, November 5, 2018 9:51 AM To: json-editor/json-editor json-editor@noreply.github.com Cc: Michael Rehder Michael.Rehder@Amdocs.com; Mention mention@noreply.github.com Subject: Re: [json-editor/json-editor] pattern of greater than 35 chars doesn't display properly (#140)
I think the value could be even higher, like 500. I don't know about issues with large patterns.
CC: @marc7000https://github.com/marc7000 @jdornhttps://github.com/jdorn
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/json-editor/json-editor/issues/140#issuecomment-435902366, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALnH5-guvlgqc9A9Ae2mbC6aD0thXT1yks5usFBegaJpZM4VR2Ro. “Amdocs’ email platform is based on a third-party, worldwide, cloud-based system. Any emails sent to Amdocs will be processed and stored using such system and are accessible by third party providers of such system on a limited basis. Your sending of emails to Amdocs evidences your consent to the use of such system and such processing, storing and access”.
Ok. I have changed the 50 character limit to 500 now.
Expected behavior
GIven this variant in the pattern of a string "IDs": { "type": "array",
There should be a pick of the pattern to use.
Actual behavior
Only the first pattern is shown. A second pattern called "type" is shown.
Steps to reproduce the behavior
Use a pattern of greater than 35 char length in an anyOf of patterns. Any of the patterns and they show as "type" on the UI.
https://json-editor.github.io/json-editor/?schema=N4IgLglmA2CmIC4Q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gEsALngD6AYzoAbBoQDEfAdwAM65iHYYAJmUI4scgugXSsYkXSaxgAX3QAHPGJgJQYyq8J66rNrY+IQA6iYSpCAOyA5AAA=&prompt_before_delete&theme=bootstrap2&iconlib=fontawesome4&object_layout=normal&show_errors=interaction