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

Uncaught (in promise) TypeError: n is null #389

Closed
6 tasks done
hexagon6 opened this issue Dec 7, 2022 · 0 comments
Closed
6 tasks done

Uncaught (in promise) TypeError: n is null #389

hexagon6 opened this issue Dec 7, 2022 · 0 comments
Labels
to triage This issue needs to be triaged

Comments

@hexagon6
Copy link
Contributor

hexagon6 commented Dec 7, 2022

Describe the bug

When changing an input in a bound variable of a story which is available under "Controls" UI, I get the following error in the console:

Uncaught (in promise) TypeError: n is null.

I figured out that in util.js there is a check for an object, and an access to $$.
If the value is null the typeof object test succeeds (since null is type of object) and access to $$ is tried, in which case the execution of the code halts on the aforementionent error, which freezes histoire any updates on inputs in the control panel.

I am providing a fix in a PR.

The solution would be to change the access to $$ like this:

old

    if (typeof value === 'object' && value.$$) continue

new

    if (typeof value === 'object' && value?.$$) continue

Reproduction

<script>
  /**
   * @type {{ Story: any; Variant: any; Text: any; }}
   */
  export let Hst

  let text = 'tag: text'
</script>

<Hst.Story title="todo.svelte" layout={{ type: 'grid', width: 500 }}>
  <Hst.Variant>
    <div>
      {text}
    </div>
    <svelte:fragment slot="controls">
      <Hst.Text bind:value={text} title="text" />
    </svelte:fragment>
  </Hst.Variant>
</Hst.Story>

System Info

latest ubuntu 22.04

Used Package Manager

npm

Validations

@hexagon6 hexagon6 added the to triage This issue needs to be triaged label Dec 7, 2022
hexagon6 added a commit to hexagon6/histoire that referenced this issue Dec 7, 2022
Akryum pushed a commit that referenced this issue Dec 9, 2022
@Akryum Akryum closed this as completed Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants