Merge pull request #76 from InsanusMokrassar/0.5.1

0.5.1
This commit is contained in:
2023-01-13 13:36:26 +06:00
committed by GitHub
3 changed files with 77 additions and 76 deletions

View File

@@ -1,5 +1,9 @@
# Changelog
## 0.5.1
* Fixes in new `Dialog`s
## 0.5.0
* Fully rework `Dialog` elements

View File

@@ -9,4 +9,4 @@ android.enableJetifier=true
# Project data
group=dev.inmo
version=0.5.0
version=0.5.1

View File

@@ -8,8 +8,6 @@ import dev.inmo.jsuikit.modifiers.*
import org.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.renderComposableInBody
import org.w3c.dom.HTMLDivElement
import org.w3c.dom.MutationObserver
import org.w3c.dom.MutationObserverInit
import kotlin.random.Random
import kotlin.random.nextUInt
@@ -31,9 +29,11 @@ fun Dialog(
removeOnHide: Boolean = true,
bodyBuilder: ContentBuilder<HTMLDivElement> = {}
) {
val drawDiv = remember { mutableStateOf(true) }
val composition = remember {
val draw = remember { mutableStateOf(true) }
remember {
renderComposableInBody {
if (draw.value) {
Div(
{
if (modifiers.none { it is UIKitModal.WithCustomAttributes }) {
@@ -70,7 +70,7 @@ fun Dialog(
onDispose {
drawDiv.value = false
draw.value = false
}
}
@@ -114,19 +114,16 @@ fun Dialog(
}
}
}
}
if (drawDiv.value) {
Div({
hidden()
ref {
onDispose {
composition.dispose()
draw.value = false
}
}
})
} else {
runCatching { composition.dispose() }
}
}
@Composable