Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the diagnostic path error #2013

Merged
merged 2 commits into from
Feb 20, 2020
Merged

fix: the diagnostic path error #2013

merged 2 commits into from
Feb 20, 2020

Conversation

lei9444
Copy link
Contributor

@lei9444 lei9444 commented Feb 19, 2020

Description

the diagnostic path is wrong
the format is like 'path#type#property'

Task Item

Closes #1972

Screenshots

image

image

@lei9444 lei9444 changed the title fix the diagnostic path error fix: the diagnostic path error Feb 19, 2020
Copy link
Contributor

@a-b-r-o-w-n a-b-r-o-w-n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine but I have a question why we need to do this? Shouldn't the json path be enough to route the diagnostics to fields in the form?

@lei9444
Copy link
Contributor Author

lei9444 commented Feb 20, 2020

This is fine but I have a question why we need to do this? Shouldn't the json path be enough to route the diagnostics to fields in the form?

Hi @a-b-r-o-w-n , I have talked about this with @alanlong9278 ,If I can do this in shell, Alan can find the fields more easier.

@alanlong9278
Copy link
Contributor

This is fine but I have a question why we need to do this? Shouldn't the json path be enough to route the diagnostics to fields in the form?

Hi, @a-b-r-o-w-n It was done for get formErrors,the filter condition needs to split path, type and props from diagnostics in form editor.

const formErrors = useMemo(() => {
    if (props.currentDialog && props.currentDialog.diagnostics) {
      const currentPath = props.focusPath.replace('#', '');
      const diagnostics = get(props.currentDialog, 'diagnostics', [] as Diagnostic[]);

      return diagnostics.reduce((errors, d) => {
        const [dPath, dType, dProp] = d.path?.split('#') || [];
        const dPropName = dProp
          ?.replace('[', '')
          ?.replace(']', '')
          ?.replace('.', '');

        if (dPath === currentPath && dType === type && dPropName) {
          errors[dPropName] = d.message;
        }

        return errors;
      }, {});
    }

    return {};
  }, [props.currentDialog]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants