mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
fix(composedmodal): focus and event
This commit is contained in:
parent
f355f52071
commit
023447e9a8
1 changed files with 10 additions and 4 deletions
|
@ -17,6 +17,8 @@
|
|||
let outerModal = undefined;
|
||||
let innerModal = undefined;
|
||||
|
||||
let opened = false;
|
||||
|
||||
setContext('ComposedModal', {
|
||||
closeModal: () => {
|
||||
open = false;
|
||||
|
@ -45,11 +47,15 @@
|
|||
});
|
||||
|
||||
afterUpdate(() => {
|
||||
if (open) {
|
||||
if (opened) {
|
||||
if (!open) {
|
||||
opened = false;
|
||||
dispatch('close');
|
||||
document.body.classList.add(cx('--body--with-modal-open'));
|
||||
}
|
||||
} else if (open) {
|
||||
opened = true;
|
||||
dispatch('open');
|
||||
document.body.classList.add(cx('--body--with-modal-open'));
|
||||
} else {
|
||||
dispatch('close');
|
||||
document.body.classList.remove(cx('--body--with-modal-open'));
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue