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

Computed value does not update when data updates #2071

Open
AniaKru95 opened this issue May 25, 2023 · 0 comments
Open

Computed value does not update when data updates #2071

AniaKru95 opened this issue May 25, 2023 · 0 comments

Comments

@AniaKru95
Copy link

Subject of the issue

I change data values to display some chunk of template.
This chunks depend on computed property, but it never change.

Steps to reproduce

Template:

  <apexchart v-if="isSingleChartActive"
             type="bar"
             height="700px"
             :options="columnChartOpts"
             :series="columnChartSeries"/>

Computed variable

const isSingleChartActive = computed(() => columnChartSeries.length !== 0 && props.isSingleChart)

Prop variable

const props = withDefaults(defineProps<Props>(), {
    isSingleChart: true
})

Data variable

const columnChartSeries = reactive([])

Expected behaviour

Computed value should also change

Actual behaviour

it('should display single chart2', async () => {
    const wrapper = await mount(MyChart,
        {
            propsData: {
                isSingleChart: true,
            },
            global: {
                stubs: {
                    apexchart: true
                }
            }
        })
    expect(wrapper.find("apexchart-stub").exists()).toBeFalsy() //true
    wrapper.vm.columnChartSeries = [{
        name: "dummy",
        data: [{"10:00": 25}],
        system: "pod"
    }]
    await nextTick()
    console.log(wrapper.vm.columnChartSeries.length !== 0)    //true
    console.log(wrapper.vm.isSingleChart)    //true
    console.log(wrapper.vm.isSingleChartActive)    //false

    expect(wrapper.find("apexchart-stub").exists()).toBeTruthy()
})

isSingleChartActive should be also true!

I've tried to setTimeout, but does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant