quasar icon indicating copy to clipboard operation
quasar copied to clipboard

Dialog plugin not focusing on text field when it is triggered by a QMenu list item (on Android)

Open michelpetrovic opened this issue 5 years ago • 3 comments

Describe the bug (Found on Android): When there is a QMenu on the page, inside a QBtn, the dialog plugin (i.e. $q.dialog) does not focus the text field when the dialog is opened by a QMenu component.

Given the following prompt:

prompt () {
      this.$q.dialog({
        title: 'Prompt',
        message: 'What is your name? (Minimum 3 characters)',
        prompt: {
          model: '',
          isValid: val => val.length > 2,
          type: 'text' // optional
        },
        cancel: true,
        persistent: true
      }).onOk(data => {
        // console.log('>>>> OK, received', data)
      })
    }

This works as expected:

<q-btn @click="prompt" />

This doesn't:

<q-btn icon="menu">
  <q-menu>
    <q-list>
      <q-item @click="prompt">
        <q-item-section>Show prompt</q-item-section>
      </q-item>
    </q-list>
  </q-menu>
</q-btn>

Codepen/jsFiddle/Codesandbox (required) Was not able to reproduce on a web page, only on an Android device and Android emulator.

To Reproduce See above

Expected behavior When displaying the prompt, the text field should receive the focus and the soft keyboard open.

Screenshots I have attached two gifs, one showing a prompt with the expected focus, and another with the focus not working. It's from the same app. qBtn_working qMenu_broken

Platform (please complete the following information): OS: Android Emulator on Ubuntu 20.10. Android: 10

Additional context It seems as if the menu list and/or animation interferes with the text field focus.

michelpetrovic avatar Dec 15 '20 20:12 michelpetrovic

Hello. Can you please do a little test for me?

Replace the quasar entry in package.json with "quasar": "https://github.com/pdanpdan/quasar#quasar-pdan-v1.14.7-beta.7", and do a yarn and start the application on the mobile and check if it fixes the problem.

pdanpdan avatar Dec 15 '20 22:12 pdanpdan

Hi, I tried it on the emulator and the problem persists, unfortunately.

michelpetrovic avatar Dec 16 '20 08:12 michelpetrovic

Then the only quick solution I can see is to open the dialog with a small timeout. Even a setTimeout(...,0) might work. I'll try to find out the root cause.

pdanpdan avatar Dec 16 '20 12:12 pdanpdan