mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
fix(modal): focus
This commit is contained in:
parent
7dd8a5d350
commit
1340815417
1 changed files with 8 additions and 6 deletions
|
@ -19,7 +19,7 @@
|
|||
export let size = undefined;
|
||||
export let style = undefined;
|
||||
|
||||
import { createEventDispatcher, afterUpdate, onDestroy } from 'svelte';
|
||||
import { createEventDispatcher, afterUpdate, onDestroy, onMount } from 'svelte';
|
||||
import Close20 from 'carbon-icons-svelte/lib/Close20';
|
||||
import { cx } from '../../lib';
|
||||
import Button from '../Button';
|
||||
|
@ -36,12 +36,14 @@
|
|||
node.focus();
|
||||
}
|
||||
|
||||
afterUpdate(() => {
|
||||
if (open) {
|
||||
onMount(() => {
|
||||
focus();
|
||||
dispatch('open');
|
||||
document.body.classList.add(cx('--body--with-modal-open'));
|
||||
} else {
|
||||
})
|
||||
|
||||
afterUpdate(() => {
|
||||
if (!open) {
|
||||
dispatch('close');
|
||||
document.body.classList.remove(cx('--body--with-modal-open'));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue