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

When using the selected slot of ui.select, the panel is not displayed immediately. #2518

Open
CrystalWindSnake opened this issue Feb 5, 2024 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@CrystalWindSnake
Copy link
Contributor

Description

When using the selected slot of ui.select as text, need to click twice for the options panel to be displayed.
In addition, the selected-item slot also has this problem

# When chip is clicked, the options panel is displayed normally
select1 = ui.select(list("ab"), value="a")
with select1.add_slot("selected"):
    with ui.element("q-chip"):
        ui.label("a")


#  need to click on the chip twice for the options panel to appear
select2 = ui.select(list("ab"))
select2.add_slot(
    "selected",
    r"""
<q-chip>
  <div>{{ 'a' }}</div>
</q-chip>
""",
)

未命名项目

@falkoschindler falkoschindler added the bug Something isn't working label Feb 6, 2024
@falkoschindler
Copy link
Contributor

Hu, this is strange. Thanks for reporting this issue, @CrystalWindSnake!
Does anyone have an idea why this happens?

Here's an even more compact reproduction:

with ui.select(['a', 'b']).add_slot('selected'):
    with ui.element('q-chip'):
        ui.label('a')

ui.select(['a', 'b']).add_slot('selected', r'<q-chip><div>a</div></q-chip>')

@falkoschindler falkoschindler added the help wanted Extra attention is needed label Feb 6, 2024
@CrystalWindSnake
Copy link
Contributor Author

I checked both cases and they end up generating the same html snippet. Don't understand why there is a difference in effect

@CrystalWindSnake
Copy link
Contributor Author

@falkoschindler I seem to have found the problem, here is a reproduction of the problem using quasar.

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet"
        type="text/css">
    <link href="https://cdn.jsdelivr.net/npm/quasar@2.14.5/dist/quasar.prod.css" rel="stylesheet" type="text/css">
</head>

<body>
    <div id="works-app"> </div>
    <div id="issue-app"> </div>


    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/quasar@2.14.5/dist/quasar.umd.prod.js"></script>

    <script type="module">
        const { createApp } = Vue

        const works_app = createApp({
            render() {
                return Vue.h(Quasar.QSelect, {
                    filled: true,
                    modelValue: [],
                    options: ['a', 'b'],
                    label: "works",
                    multiple: true,
                    emitValue: true,
                    mapOptions: true
                }, {
                    selected: (props) => Vue.h(Quasar.QChip, {
                        innerHTML: 'a'
                    })
                })
            }
        }
        ).use(Quasar).mount('#works-app');


        const issue_app = createApp({
            render() {
                return Vue.h(Quasar.QSelect, {
                    filled: true,
                    modelValue: [],
                    options: ['a', 'b'],
                    label: "Multi with toggle",
                    multiple: true,
                    emitValue: true,
                    mapOptions: true
                }, {
                    selected: (props) => Vue.h({
                        template: `<q-chip>a</q-chip>`
                    })
                })
            }
        }
        ).use(Quasar).mount('#issue-app');

    </script>
</body>

</html>

When we render the entire slot string as a component into a virtual node, it seems that this virtual node will be rebuilt when clicked, ultimately causing the click to fail.

In addition, this problem leads to another small issue. When using a checkbox in a table slot, the checkbox's toggle transition animation will fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants