Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(V-Menu): only closing menu in closeParents if persistent is not set #19782

Merged
merged 3 commits into from
May 14, 2024
Merged

fix(V-Menu): only closing menu in closeParents if persistent is not set #19782

merged 3 commits into from
May 14, 2024

Conversation

noahbare
Copy link
Contributor

@noahbare noahbare commented May 8, 2024

Description

When using nested v-menus, if the parent has persistent set to true, it should remain open on an outside click even when the child menu is closed with an outside click.
When using a v-menu to get input from the user we set the parent menu to be persistent and expect it to remain open until the user cancels/saves.

  • Added check to closeParents function to take into account if the menu is persistent or not.

This is related to #19239, which kept the parent menu open if the child menu was closed by clicking on the parent menu content. This extends this check to account for the parent being persistent, thus keeping the menu open even on outside clicks and resolves #19780.

Markup:

<template>
  <v-app>
    <v-container>
      <v-btn id="rootButton">
        Open Menu 1
      </v-btn>
      <v-menu
        v-model="menu1"
        :close-on-content-click="false"
        activator="#rootButton"
        height="300px"
        location="top"
        width="260px"
        persistent
      >
        <v-card>
          <v-card-title>
            Menu 1
          </v-card-title>
          <v-card-item>
            <v-row>
              <v-col cols="12">
                <v-text-field v-model="menu1Text" label="Some text" />
              </v-col>
              <v-col cols="12">
                <v-menu
                  v-model="menu2"
                  :close-on-content-click="false"
                >
                  <template #activator="{ props }">
                    <div v-bind="props" z-index="2000">
                      <v-text-field
                        :model-value="date"
                      />
                    </div>
                  </template>
                  <v-date-picker
                    v-model="date"
                    theme="legacy"
                    @update:model-value="menu2 = false"
                  />
                </v-menu>
              </v-col>
            </v-row>
          </v-card-item>
          <v-card-actions>
            <v-spacer />

            <v-btn
              variant="text"
              @click="menu1 = false"
            >
              Cancel
            </v-btn>
            <v-btn
              color="primary"
              variant="text"
              @click="menu1 = false"
            >
              Save
            </v-btn>
          </v-card-actions>
        </v-card>
      </v-menu>
    </v-container>
  </v-app>
</template>

<script setup lang="ts">
  import { Ref, ref } from 'vue'

  const menu1: Ref<boolean> = ref(false)
  const menu2: Ref<boolean> = ref(false)
  const menu1Text: Ref<string> = ref('')
  const date: Ref<Date> = ref(new Date())
</script>

@noahbare noahbare requested a review from KaelWD May 8, 2024 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VOverlay VOverlay T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.6.4] V-Menu Persistent Parent Closed by Child
3 participants