pnp / pnp/sp-dev-fx-controls-react

Dynamic form TaxonomyFieldType NPE exception on defaultValue

Open
#1,667 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
TypeScript
Stars
433
Forks
418
Avg merge
5d 6m
Merged PRs (30d)
19

Description

Category

[ ] Enhancement

[x] Bug

[ ] Question

Version

Please specify what version of the library you are using: [3.15.0]

Observed Behavior

When the dynamic form is initializing, there seems to be an issue when loading a TaxonomyField. The Default value is null, but there is no null check in the code, which results in the following error:

Error get field informations TypeError: Cannot read properties of null (reading 'split')
    at DynamicForm.js:534:66
    at step (DynamicForm.js:58:1)
    at Object.next (DynamicForm.js:39:45)
    at step (DynamicForm.js:43:1)
    at Object.next (DynamicForm.js:39:45)
    at fulfilled (DynamicForm.js:30:42)

image

Solution

Issue is here:
https://github.com/pnp/sp-dev-fx-controls-react/blob/master/src/controls/dynamicForm/DynamicForm.tsx#L624

In my opinion, it should follow the same checks as the TaxonomyFieldMulti at L593, which does contain the null check:
https://github.com/pnp/sp-dev-fx-controls-react/blob/master/src/controls/dynamicForm/DynamicForm.tsx#L593

I'm not that familiar with working on public repos, so if anyone would want to create a PR, that would be great :) Thanks in advance!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/controls/dynamicForm/DynamicForm.tsx around line 624, where the TaxonomyField default value is processed. Compare that logic with the null check for TaxonomyFieldMulti around line 593, then verify that a dynamic form with a null taxonomy default value initializes without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.