matyunya / smelte

UI framework with material components built with Svelte and Tailwind CSS
https://smeltejs.com/
MIT License
1.53k stars 114 forks source link

datepicker closing modal #157

Open sinistra opened 4 years ago

sinistra commented 4 years ago

I am using the datepicker inside a modal form. When the calendar widget is displayed and the user clicks on either '<' or '>' (previous/next month) the datepicker and the parent modal are closed. btw, the modal has 'persistent' set, so it should not close.

Has anyone experienced this or can provide any advice on how to manage it?

micha-lmxt commented 4 years ago

Hi, this seems to work for me:

/// App.svelte
<script lang="ts">
    import Dialog_ from 'smelte/src/components/Dialog';
    import { Button, DatePicker } from 'smelte/src';
    export let name: string;
    let value=false
</script>

<main>
    <Button on:click={()=>{value=true}}>Open Dialog</Button>    
    <Dialog_ bind:value persistent>
        <DatePicker/>
    <div slot="actions">
        <Button on:click={()=>{value=false}}>Close</Button>
    </div>
    </Dialog_>
</main>

Could you share some example code?

sinistra commented 4 years ago

I ended up writing my own datePicker, but I suspect the problem is a submit that is propagating up from the datePicker thru the modal.

csaltos commented 3 years ago

just in case ->

if you overwrite the whitelistPatterns parameter, ensure you did not remove accidentally the date picker part.

The original whitelistPatterns parameter is as follows:


const defaultWhitelistPatterns = [
  // for JS ripple
  /ripple/,
  // date picker
  /w\-.\/7/
];```
muhsim commented 3 years ago

Additionally, there seems to be no way of automatically opening datePicker when Dialog that contains it opened.