From d19046fe9f290a3d136b95b2900f2a8ab2fb96cc Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 20 Sep 2024 11:20:21 +0200 Subject: [PATCH 1/2] feat: don't error field on non-syntax errors --- src/components/entries/FEEL/Feel.js | 11 ++++++----- test/spec/components/Feel.spec.js | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/components/entries/FEEL/Feel.js b/src/components/entries/FEEL/Feel.js index 1e1ee2e3..e302c1e8 100644 --- a/src/components/entries/FEEL/Feel.js +++ b/src/components/entries/FEEL/Feel.js @@ -130,14 +130,15 @@ function FeelTextfieldComponent(props) { } }; - const handleLint = useStaticCallback(lint => { + const handleLint = useStaticCallback((lint = []) => { - if (!(lint && lint.length)) { + const syntaxError = lint.some(report => report.type === 'Syntax Error'); + + if (syntaxError) { + onError('Unparsable FEEL expression.'); + } else { onError(undefined); - return; } - - onError('Unparsable FEEL expression.'); }); const handlePopupOpen = (type = 'feel') => { diff --git a/test/spec/components/Feel.spec.js b/test/spec/components/Feel.spec.js index c0b25133..fdbf538c 100644 --- a/test/spec/components/Feel.spec.js +++ b/test/spec/components/Feel.spec.js @@ -1986,6 +1986,26 @@ describe('', function() { }); + it('should not indicate field error on non-syntax errors', async function() { + + // given + const clock = sinon.useFakeTimers(); + const result = createFeelField({ container, getValue: () => '= friend[0]', feel: 'required' }); + + // when + // trigger debounced validation + await act(() => { clock.tick(1000); }); + await act(() => { clock.restore(); }); + + // then + await waitFor(() => { + const entry = domQuery('.bio-properties-panel-entry', result.container); + + expect(isValid(entry)).to.be.true; + }); + }); + + it('should show global error over local error', async function() { // given From 538fb03aa69ee85b1376608cd257a94a2a5249fc Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 20 Sep 2024 11:20:44 +0200 Subject: [PATCH 2/2] deps: bump to @bpmn-io/feel-lint@1.3.1 fix: turn `first-item` validation into warning --- package-lock.json | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 120129d3..3cec1d34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -533,10 +533,9 @@ } }, "node_modules/@bpmn-io/feel-lint": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@bpmn-io/feel-lint/-/feel-lint-1.3.0.tgz", - "integrity": "sha512-wykQUqGb/wWoQI13M6T5iOPrQUwzLfI7U/SVENx3nOn634L+grQtMCULeAtF0ZVkw8wAuygIQ2m8H/mcUnWo5w==", - "license": "MIT", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@bpmn-io/feel-lint/-/feel-lint-1.3.1.tgz", + "integrity": "sha512-wcFkJKhOm/iqCt5bzkKvxL5Dr9wKwUD+t164bQYbJsTYouAqmkkxiGsoqck42hXwdIhMSguZ+vqQ3hj5QdiYCA==", "dependencies": { "@codemirror/language": "^6.10.0", "lezer-feel": "^1.2.3" @@ -10645,9 +10644,9 @@ } }, "@bpmn-io/feel-lint": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@bpmn-io/feel-lint/-/feel-lint-1.3.0.tgz", - "integrity": "sha512-wykQUqGb/wWoQI13M6T5iOPrQUwzLfI7U/SVENx3nOn634L+grQtMCULeAtF0ZVkw8wAuygIQ2m8H/mcUnWo5w==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@bpmn-io/feel-lint/-/feel-lint-1.3.1.tgz", + "integrity": "sha512-wcFkJKhOm/iqCt5bzkKvxL5Dr9wKwUD+t164bQYbJsTYouAqmkkxiGsoqck42hXwdIhMSguZ+vqQ3hj5QdiYCA==", "requires": { "@codemirror/language": "^6.10.0", "lezer-feel": "^1.2.3"