question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug Report] v-menu auto property doesn't properly center the menu items relative to the activator

See original GitHub issue

Versions and Environment

Vuetify: 1.5.5 Vue: 2.6.8 Browsers: Chrome 70.0.3538.77 OS: Linux x86_64

Steps to reproduce

Create a v-menu with a button as an activator and put the auto prop on v-menu.

<div id="app">
  <v-app id="inspire">
    <div class="text-xs-center">
      <v-menu
        v-model="menu"
        :close-on-content-click="false"
        auto
        offset-y
      >
        <template v-slot:activator="{ on }">
          <v-btn
            color="indigo"
            dark
            v-on="on"
          >
            Menu as Popover
          </v-btn>
        </template>
  
        <v-card>
          <v-list>
            <v-list-tile avatar>
              <v-list-tile-avatar>
                <img src="https://cdn.vuetifyjs.com/images/john.jpg" alt="John">
              </v-list-tile-avatar>
  
              <v-list-tile-content>
                <v-list-tile-title>John Leider</v-list-tile-title>
                <v-list-tile-sub-title>Founder of Vuetify.js</v-list-tile-sub-title>
              </v-list-tile-content>
  
              <v-list-tile-action>
                <v-btn
                  :class="fav ? 'red--text' : ''"
                  icon
                  @click="fav = !fav"
                >
                  <v-icon>favorite</v-icon>
                </v-btn>
              </v-list-tile-action>
            </v-list-tile>
          </v-list>
  
          <v-divider></v-divider>
  
          <v-list>
            <v-list-tile>
              <v-list-tile-action>
                <v-switch v-model="message" color="purple"></v-switch>
              </v-list-tile-action>
              <v-list-tile-title>Enable messages</v-list-tile-title>
            </v-list-tile>
  
            <v-list-tile>
              <v-list-tile-action>
                <v-switch v-model="hints" color="purple"></v-switch>
              </v-list-tile-action>
              <v-list-tile-title>Enable hints</v-list-tile-title>
            </v-list-tile>
          </v-list>
  
          <v-card-actions>
            <v-spacer></v-spacer>
  
            <v-btn flat @click="menu = false">Cancel</v-btn>
            <v-btn color="primary" flat @click="menu = false">Save</v-btn>
          </v-card-actions>
        </v-card>
      </v-menu>
    </div>
  </v-app>
</div>

Expected Behavior

In the docs it says that if you put auto prop on v-menu it will center the menu items. It should center the v-card relative to the button but it is not centered.

Actual Behavior

The v-menu item has a strange offset to the left but not fully centered.

Reproduction Link

https://codepen.io/anon/pen/aMJOaY?&editable=true&editors=101

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
martinszeltinscommented, Jul 29, 2019

@jacekkarczmarczyk How would solve centering a v-menu under its activator? @martinszeltins Have you found a solution to the problem?

No, I haven’t found a solution yet.

3reactions
talskicommented, Feb 11, 2021

If your activator and v-menu have fixed widths, it can be accomplished by setting nudge-left property:

nudge-left = (vMenuWidth - activatorWidth)/2

Example:

https://codepen.io/talski/pen/zYoojGZ?editors=1010

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vuetify menu component auto property doesn't center the ...
I am using the Vuetify menu (as a popover) and in the docs it says that the auto property centers the menu items...
Read more >
The Centered Text element - HTML - MDN Web Docs - Mozilla
The <center> HTML element is a block-level element that displays its block-level or inline contents centered horizontally within its containing element. The ...
Read more >
You cannot center the text in a column of an inserted table in ...
Describes a problem in which you cannot center the text in a column of an inserted table in Word. Provides three workarounds.
Read more >
How to Center Align Items in CSS with 4 Solid Methods.
In a nutshell, a block element can use the text-align property to horizontally center align any text or inline elements inside of it...
Read more >
A Practical Guide to Centering in CSS - Stack Diary
Looking for a quick solution to center a text or a div element in CSS? ... I'm certain that the problem with centering...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found