vuetify icon indicating copy to clipboard operation
vuetify copied to clipboard

[Bug Report] [v-autocomplete] Wrong menu position on items change if it is already open

Open alessandrome-sinerbit opened this issue 5 years ago • 8 comments

Environment

Vuetify Version: 2.2.8 Vue Version: 2.6.11 Browsers: Chrome 79.0.3945.117 OS: Mac OS 10.15.2

Steps to reproduce

While the autocomplete menu is open and items of the autocomplete change (in the example from empty array to a 5 elements array), the menu doesn't change position until I close and re-open it.

Expected Behavior

I expect that after the item list of the autocomplete change, it will adjust the dropdown menu position, also if it already open

Actual Behavior

Position of dropdown position doesn't change until the dropdown menu is not reopened

Reproduction Link

https://codepen.io/alessandro-mesti-sinerbit/pen/ZEYNyjW?editors=1010

alessandrome-sinerbit avatar Jan 29 '20 12:01 alessandrome-sinerbit

That has nothing to do with auto or default styles https://codepen.io/jkarczm/pen/XWJvVZM?editors=1010

jacekkarczmarczyk avatar Feb 03 '20 03:02 jacekkarczmarczyk

Then I'll need some additional information.

johnleider avatar Feb 03 '20 07:02 johnleider

in the demo code snippet I posted, during item loading the selected autocomplete correctly show a dropdown menu on top of the component: Correct drop-down menu on focused v-autcomplete

When item loading is completed. the dropdown menu of focused autocomplete doesn't change position, allowing the dropdown menu to overflow the normal screen dimension: Wrong menu position after loading

If I deselect and refocus the autocomplete, the dropdown, closing and reopening itself, change position on top of the autocomplete, avoiding to go off-screen: Correctly repositioned menu

alessandrome-sinerbit avatar Feb 03 '20 09:02 alessandrome-sinerbit

calling updateMenuDimensions after updating the items seems to fix the issue

reza-akbari avatar Feb 25 '20 15:02 reza-akbari

That won't for v-select though, it has the same problem

jacekkarczmarczyk avatar Feb 29 '20 05:02 jacekkarczmarczyk

I managed to solve this problem in the following way: Clean the list on each request

watch: {
      async search(val) {
        this.items = []; // important 🤓 
        this.items = await this.fetchDataFromApi();
    },
  },

helderhernandez avatar Mar 02 '22 11:03 helderhernandez

I managed to solve this problem in the following way: Clean the list on each request

watch: {
      async search(val) {
        this.items = []; // important 🤓 
        this.items = await this.fetchDataFromApi();
    },
  },

Doesn't seem to work in my case. I already had a clear on my items but doesn't seem to fix it.

ricardovanlaarhoven avatar Jul 14 '22 10:07 ricardovanlaarhoven

My workaround:

<v-autocomplete ref="autocomplete" :items="items">
computed: {
    items() { ... },
},
watch: {
    items: {
      deep: true,
      handler() {
        this.$nextTick(() => {
          this.$refs.autocomplete.updateMenuDimensions();
        });
      },
    },
  },

davidbielik avatar Aug 19 '22 12:08 davidbielik

This Issue is being closed due to inactivity.

If you have any questions, please reach out to us in our Discord community.

johnleider avatar Aug 09 '23 15:08 johnleider