Skip to content

SMUI Bottom App Bar raises error when destroyed during resizing window. #690

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

Open
okaluk opened this issue Mar 31, 2025 · 0 comments
Open

Comments

@okaluk
Copy link

okaluk commented Mar 31, 2025

Hello, first of all, really nice work and thanks for sharing it with us!

I started using this library for a small project and wanted to use the bottom-app-bar for my mobile view. I use a media query to check if my width is higher than 600px, if so, the bottom-app-bar is unmounted from the dom. actually, this throws an Uncaught TypeError: Cannot read properties of null (reading 'getBoundingClientRect').

I already found a fix for this in BottomAppBar.svelte:175:

return getElement()?.getBoundingClientRect().height;

i would like to pull request this, if you don't mind.

code example:

<script lang="ts">
  import { MediaQuery } from "svelte/reactivity";
  import BottomAppBar, {
    AutoAdjust,
  } from '@smui-extra/bottom-app-bar';

  let mobile = new MediaQuery('(max-width: 600px)');
</script>

{#if mobile.current}
  <BottomAppBar>
    <p> test bottom app bar </p>
  </BottomAppBar>
{:else}
  <p> test no bottom app bar </p>
{/if}
okaluk added a commit to okaluk/svelte-material-ui that referenced this issue Mar 31, 2025
…otential error by returning null if element is not in DOM.
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

1 participant