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

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

Closed
alessandrome-sinerbit opened this issue Jan 29, 2020 · 10 comments
Assignees
Labels
C: VSelect VSelect T: bug Functionality that does not work as intended/expected

Comments

@alessandrome-sinerbit
Copy link

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

@ghost ghost added the S: triage label Jan 29, 2020
@johnleider johnleider self-assigned this Feb 2, 2020
@jacekkarczmarczyk
Copy link
Member

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

@johnleider
Copy link
Member

Then I'll need some additional information.

@alessandrome-sinerbit
Copy link
Author

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

@reza-akbari
Copy link

calling updateMenuDimensions after updating the items seems to fix the issue

@jacekkarczmarczyk
Copy link
Member

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

@Leespiker Leespiker added T: bug Functionality that does not work as intended/expected and removed S: triage labels Apr 8, 2020
@helderhernandez
Copy link

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();
    },
  },

@ricardovanlaarhoven
Copy link
Contributor

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.

@davidbielik
Copy link
Contributor

My workaround:

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

@johnleider
Copy link
Member

This Issue is being closed due to inactivity.

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

@AleksanderGjinollari
Copy link

I don't know if this will work for you, but adding the attach prop to v-autocomplete solved it for me.

<v-autocomplete
  :attach="true"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VSelect VSelect T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants