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

Slotted QSelect does not start on selected option #15788

Closed
BenJackGill opened this issue May 4, 2023 · 5 comments
Closed

Slotted QSelect does not start on selected option #15788

BenJackGill opened this issue May 4, 2023 · 5 comments
Labels
area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues

Comments

@BenJackGill
Copy link

BenJackGill commented May 4, 2023

What happened?

I have a long list of options in a slotted QSelect element.

One of those options has been pre-selected, but when then list opens it shows the very top of the options list, not the selected option.

If the list is closed and reopened it will then correctly show the selected option.

I could only get this bug to show when the QSelect was a slot of QInput. The bug does not happen when using QSelect on it's own.

Also this might be an old bug that as resurfaced because I found this very similar issue that was closed as resolved: #4394

What did you expect to happen?

The list should open scrolled to the currently selected option.

Reproduction URL

https://stackblitz.com/edit/quasarframework-yqsvxg?file=src/pages/IndexPage.vue

How to reproduce?

  1. Go to the provided reproduction link
  2. Click on the country select
  3. See that the list is scrolled to the top, not the currently selected "County 112". This is the error.
  4. Close the list and reopen it again. It will now be scrolled to the selected "County 112". This is how it should look the first time it is opened.

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Components (quasar)

Platforms/Browsers

Chrome

Quasar info output

Operating System - Darwin(22.4.0) - darwin/arm64
NodeJs - 16.19.1

Global packages
  NPM - 8.19.3
  yarn - Not installed
  @quasar/cli - 2.0.1
  @quasar/icongenie - 2.5.4
  cordova - Not installed

Important local packages
  quasar - 2.11.10 -- Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time
  @quasar/app-vite - 1.2.2 -- Quasar Framework App CLI with Vite
  @quasar/extras - 1.16.3 -- Quasar Framework fonts, icons and animations
  eslint-plugin-quasar - Not installed
  vue - 3.2.47 -- The progressive JavaScript framework for building modern web UI.
  vue-router - 4.1.6
  pinia - Not installed
  vuex - Not installed
  vite - 2.9.15 -- Native-ESM powered web dev build tool
  eslint - 8.36.0 -- An AST-based pattern checker for JavaScript.
  electron - Not installed
  electron-packager - Not installed
  electron-builder - Not installed
  register-service-worker - 1.7.2 -- Script for registering service worker, with hooks
  @capacitor/core - Not installed
  @capacitor/cli - Not installed
  @capacitor/android - Not installed
  @capacitor/ios - Not installed

Quasar App Extensions
  *None installed*

Networking
  Host - BenBookAir.lan
  en0 - 192.168.8.149

Relevant log output

No response

Additional context

No response

@github-actions github-actions bot added area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite labels May 4, 2023
@BenJackGill BenJackGill changed the title QSelect does not start on selected option Slotted QSelect does not start on selected option May 4, 2023
@pdanpdan
Copy link
Collaborator

pdanpdan commented May 4, 2023

I can reproduce it - I'll take a look

@BenJackGill
Copy link
Author

BenJackGill commented May 4, 2023

Upon further testing I think it has to do with the #option slot. It works ok if I remove that.

@BenJackGill
Copy link
Author

It also seems that clicking one those options from the #option slot does not update the selected option. This is probably a related bug.

@pdanpdan
Copy link
Collaborator

pdanpdan commented May 4, 2023

Two things:

  • :virtual-scroll-slice-size="countryOptions?.length" makes virtual scroll render all options all the time :) - why?
  • countryOptionItemHeight starts as 0, so all heights are initially estimated as 0 height - provide a better initial estimation (and in no case 0)

But I would remove the resize observer - it is pointless

For tweaking the design take a look here: https://codepen.io/pdanpdan/pen/XWYWwZJ

@pdanpdan pdanpdan closed this as completed May 4, 2023
@BenJackGill
Copy link
Author

BenJackGill commented May 5, 2023

Thanks! That works!

I am more clear now about the use and purpose of virtual-scroll-item-size.

And for :virtual-scroll-slice-size="countryOptions?.length" I wanted all options to render at once so I could calculate the widest possible option width, and set that value to the options min-width. This is because I don't like the options menu shrinking and growing based on the values that are loaded or filtered. Is there a better way of doing this without hardcoding the width?

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

2 participants