Skip to content

Commit

Permalink
refactor: use existing $refs declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Jun 29, 2022
1 parent 2ae697d commit caa212c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
16 changes: 5 additions & 11 deletions packages/vuetify/src/components/VDialog/VDialog.ts
Expand Up @@ -17,7 +17,7 @@ import Toggleable from '../../mixins/toggleable'
import ClickOutside from '../../directives/click-outside'

// Helpers
import mixins, { ExtractVue } from '../../util/mixins'
import mixins from '../../util/mixins'
import { removed } from '../../util/console'
import {
convertToUnit,
Expand All @@ -37,15 +37,8 @@ const baseMixins = mixins(
Toggleable
)

interface options extends ExtractVue<typeof baseMixins> {
$refs: {
dialog: HTMLElement
content: HTMLElement
}
}

/* @vue/component */
export default baseMixins.extend<options>().extend({
export default baseMixins.extend().extend({
name: 'v-dialog',

directives: { ClickOutside },
Expand Down Expand Up @@ -188,9 +181,9 @@ export default baseMixins.extend<options>().extend({
// Double nextTick to wait for lazy content to be generated
this.$nextTick(() => {
this.$nextTick(() => {
if (!this.$refs.dialog.contains(document.activeElement)) {
if (!this.$refs.dialog?.contains(document.activeElement)) {
this.previousActiveElement = document.activeElement as HTMLElement
this.$refs.dialog.focus()
this.$refs.dialog?.focus()
}
this.bind()
})
Expand Down Expand Up @@ -232,6 +225,7 @@ export default baseMixins.extend<options>().extend({

if (
!!target &&
this.$refs.dialog &&
// It isn't the document or the dialog body
![document, this.$refs.dialog].includes(target) &&
// It isn't inside the dialog body
Expand Down
6 changes: 3 additions & 3 deletions packages/vuetify/src/mixins/dependent/index.ts
Expand Up @@ -3,10 +3,10 @@ import Vue from 'vue'
import mixins from '../../util/mixins'
import { VOverlay } from '../../components/VOverlay'

interface options extends Vue {
interface options {
$el: HTMLElement
$refs: {
content: HTMLElement
content?: HTMLElement
}
overlay?: InstanceType<typeof VOverlay>
}
Expand All @@ -31,7 +31,7 @@ function searchChildren (children: Vue[]): DependentInstance[] {
}

/* @vue/component */
export default mixins<options>().extend({
export default mixins<Vue & options>().extend({
name: 'dependent',

data () {
Expand Down
6 changes: 3 additions & 3 deletions packages/vuetify/src/mixins/detachable/index.ts
Expand Up @@ -7,13 +7,13 @@ import mixins, { ExtractVue } from '../../util/mixins'
import { consoleWarn } from '../../util/console'

// Types
import Vue, { PropOptions } from 'vue'
import { PropOptions } from 'vue'
import { VNode } from 'vue/types'

interface options extends Vue {
interface options {
$el: HTMLElement
$refs: {
content: HTMLElement
content?: HTMLElement
}
}

Expand Down

0 comments on commit caa212c

Please sign in to comment.