shopware / shopware

Shopware 6 is an open commerce platform based on Symfony Framework and Vue and supported by a worldwide community and more than 1.500 community extensions
https://shopware.com
MIT License
2.81k stars 1.02k forks source link

CmsBlock and CmsElement computed, @input and @change not working #3649

Closed thomaskral closed 6 months ago

thomaskral commented 7 months ago

PHP Version

8.3

Shopware Version

6.6.0.2

Expected behaviour

The text field should render the value from the config. When the value gets updated by the user the value should get updated in the config.

Your example from the docs:

index.js

computed: {
        dailyUrl: {
            get() {
                return this.element.config.dailyUrl.value;
            },

            set(value) {
                this.element.config.dailyUrl.value = value;
            }
        }
    },

methods: {
    createdComponent() {
        this.initElementConfig('dailymotion');
    },

    onElementUpdate(value) {
        this.element.config.dailyUrl.value = value;

        this.$emit('element-update', this.element);
    }
}

html.twig

{% block sw_cms_element_dailymotion_config %}
    <sw-text-field
          v-model="dailyUrl"
          class="swag-dailymotion-field"
          label="Dailymotion video link"
          placeholder="Enter dailymotion link..."
          @input="onElementUpdate"
          @change="onElementUpdate">
    </sw-text-field>
{% endblock %}

Actual behaviour

How to reproduce

Use the examples from your own docs:

https://developer.shopware.com/docs/guides/plugins/plugins/content/cms/add-cms-block.html https://developer.shopware.com/docs/guides/plugins/plugins/content/cms/add-cms-element.html

For text input my current workaround is using the @blur event to trigger onElementUpdate. But this is not working for select or radio elements. This makes those elements unusable at the moment.

shopware-issue-bot[bot] commented 7 months ago

We found the following existing issues which may help or are related to your topic:

kingschnulli commented 6 months ago

Seems like the docs are outdated, this is a Vue2 to Vue3 migration thing. With 6.6 it should be used something like this:

    <sw-text-field
          v-model:value="dailyUrl"
          class="swag-dailymotion-field"
          label="Dailymotion video link"
          placeholder="Enter dailymotion link..."
          @update:value="onElementUpdate">
    </sw-text-field>
mitelg commented 6 months ago

thanks for bringing this up, I made an update for the docs :v:

https://github.com/shopware/docs/pull/1359