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

Login form, basic, example v.3 -- uncaught Type Error after returning to page with this form #1955

Closed
letzfets opened this issue Sep 20, 2023 · 2 comments

Comments

@letzfets
Copy link
Contributor

Describe the bug
I'm using the login form - version 3 with Svelte.
The component loads perfectly in the first load. When navigating through the page, for example by browser forward/back or by clicking to a different route and back to the one, where the form is, the input fields of the form through TypeErrors

tw-elements.js?v=25366a27:4570 Uncaught TypeError: Cannot read properties of null (reading 'style')
    at _V._applyNotch (tw-elements.js?v=25366a27:4570:23)
    at _V._getElements (tw-elements.js?v=25366a27:4595:15)
    at tw-elements.js?v=25366a27:4578:12
    at Zl (tw-elements.js?v=25366a27:121:21)
    at _V._activate (tw-elements.js?v=25366a27:4577:5)
    at HTMLInputElement.<anonymous> (tw-elements.js?v=25366a27:4607:9)
    at HTMLDocument.i (tw-elements.js?v=25366a27:226:75)

and

Uncaught TypeError: Cannot read properties of null (reading 'removeAttribute')
    at _V._deactivate (tw-elements.js?v=25366a27:4603:7)
    at HTMLInputElement.<anonymous> (tw-elements.js?v=25366a27:4612:9)
    at HTMLDocument.i (tw-elements.js?v=25366a27:226:75)

It seems to be related to #1886 and #1640.

To Reproduce
Steps to reproduce the behavior:

  1. Mount a Login Form
  2. Change route of app
  3. Return to route with Login Form
  4. Focus on one of the input fields and remove focus

Expected behavior
Same behaviour as in the first load

Actual behavior
Two errors - see above - are thrown, the border of the input fields is missing.

Show your code

<script lang="ts">
import { onMount } from 'svelte';
onMount(async () => {
        const te = await import('tw-elements');
        te.initTE({ Input: te.Input, Ripple: te.Ripple })
    })
</script>

<section>
...code version 3 from documentation
</section>

Desktop (please complete the following information):

  • OS: macOS 12.6.8
  • Browser: chrome 116.0.5845.187

Additional context
when adding the attribute data-te-input-notch-ref to the input field hard coded, the same error occurs on the first load.

@juujisai
Copy link
Contributor

Hi! Have you tried adding options to the initTE method?

te.initTE({ Input: te.Input, Ripple: te.Ripple }, { allowReinits: true })

Let us know if anything changed

letzfets added a commit to letzfets/Tailwind-Elements that referenced this issue Sep 21, 2023
…a link, where the actual options of initTE() are defined in the quickstart guide - related to mdbootstrap#1955
@letzfets
Copy link
Contributor Author

Hi! Have you tried adding options to the initTE method?

te.initTE({ Input: te.Input, Ripple: te.Ripple }, { allowReinits: true })

Let us know if anything changed

Yes - that totally resolves the issue! Thank you very much.
The pull request updates the documentation in getting-started/optimization to reflect the changes in initTE. It might be considerable, to add a specific section to the getting-started about initTE() and potential other eposed JavaScript?

juujisai pushed a commit that referenced this issue Nov 7, 2023
…a link, where the actual options of initTE() are defined in the quickstart guide - related to #1955 (#1960)
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

No branches or pull requests

2 participants