Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 263879e

Browse files
committed
Focus helper; fine tune items
1 parent e82bfb4 commit 263879e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/components/tw-items.vue

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
>
1515
<slot :item="item" :index="index"> {{ index }}. {{ item }} </slot>
1616
</div>
17+
<slot name="empty" v-if="items.length <= 0">Empty</slot>
1718
</div>
1819
</template>
1920

src/components/tw-modal.vue

+21-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default defineComponent({
6161
props: {
6262
modelValue: {
6363
type: Boolean,
64+
default: false,
6465
},
6566
title: {
6667
type: String,
@@ -124,19 +125,38 @@ export default defineComponent({
124125
this.doCancel("escape")
125126
}
126127
},
128+
doFocus() {
129+
this.$nextTick(() => {
130+
let el = this.$el.querySelector(".focus")
131+
console.log("FOCUS", this.$el)
132+
if (el) {
133+
el.focus()
134+
}
135+
})
136+
},
127137
},
128138
created() {
129139
document?.addEventListener("keyup", this.keyPress)
130140
},
131141
watch: {
132-
modelValue(value) {
142+
async modelValue(value) {
143+
console.log("modal", this.modalValue)
133144
if (value === true) {
134145
this.$emit("didopen")
146+
this.doFocus()
135147
} else {
136148
this.$emit("willclose")
137149
}
138150
},
139151
},
152+
// mounted() {
153+
// this.$nextTick(() => {
154+
// console.log("mounted", this.modalValue)
155+
// if (this.modalValue) {
156+
// this.doFocus()
157+
// }
158+
// })
159+
// },
140160
beforeMount() {
141161
// Insert the Dialog component in the element container
142162
if (this.standalone && typeof window !== "undefined") {

0 commit comments

Comments
 (0)