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 outerModal = undefined;
|
||||||
let innerModal = undefined;
|
let innerModal = undefined;
|
||||||
|
|
||||||
|
let opened = false;
|
||||||
|
|
||||||
setContext('ComposedModal', {
|
setContext('ComposedModal', {
|
||||||
closeModal: () => {
|
closeModal: () => {
|
||||||
open = false;
|
open = false;
|
||||||
|
@ -45,11 +47,15 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
afterUpdate(() => {
|
afterUpdate(() => {
|
||||||
if (open) {
|
if (opened) {
|
||||||
dispatch('open');
|
if (!open) {
|
||||||
document.body.classList.add(cx('--body--with-modal-open'));
|
opened = false;
|
||||||
} else {
|
|
||||||
dispatch('close');
|
dispatch('close');
|
||||||
|
document.body.classList.add(cx('--body--with-modal-open'));
|
||||||
|
}
|
||||||
|
} else if (open) {
|
||||||
|
opened = true;
|
||||||
|
dispatch('open');
|
||||||
document.body.classList.remove(cx('--body--with-modal-open'));
|
document.body.classList.remove(cx('--body--with-modal-open'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue