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

Carousel v-model is not in sync when using arrow navigation buttons #2196

Closed
lunfel opened this issue Feb 3, 2020 · 2 comments
Closed

Carousel v-model is not in sync when using arrow navigation buttons #2196

lunfel opened this issue Feb 3, 2020 · 2 comments

Comments

@lunfel
Copy link
Contributor

lunfel commented Feb 3, 2020

Overview of the problem

Buefy version: [0.8.10] (0.8.9 is also affected)
Vuejs version: [2.5.18]
OS/Browser: Linux Ubuntu

Description

The v-model of Carousel component is not reactive on slide changes through previous and next arrow navigation buttons.

Steps to reproduce

  1. Create a simple b-carousel component with a v-model using this code (code from simple example from docs with added v-model):
<template>
    <b-carousel v-model="selected">
        <b-carousel-item v-for="(carousel, i) in carousels" :key="i">
            <section :class="`hero is-medium is-${carousel.color}`">
                <div class="hero-body has-text-centered">
                    <h1 class="title">{{carousel.text}}</h1>
                </div>
            </section>
        </b-carousel-item>
    </b-carousel>
    <span>{{ selected }}</span>
</template>

<script>
export default {
    data(){
        return {
            selected: 0,
            carousels: [
                { text: 'Slide 1', color: 'primary' },
                { text: 'Slide 2', color: 'info' },
                { text: 'Slide 3', color: 'success' },
                { text: 'Slide 4', color: 'warning' },
                { text: 'Slide 5', color: 'danger' }
            ]
        }
    }
}
</script>
  1. Click on navigation buttons
  2. The value of selected will stay at 0
  3. (optional) When using indicators, the value will update

Expected behavior

I would expect my v-model to be in sync with the actual selected slide regardless of the method I choose to change my slide

Actual behavior

My v-model is only in sync when using indicators

Discussion / Solution

In the docs, it states those two events:

Name Description Parameters
change Triggers when carousel item value is changed value: Boolean, value: String
input Triggers when indicator-mode value is changed value: Boolean, value: String

I feel like change should be input in fact. That way, v-model would always stay in sync with the component.

This is the api I would suggest, but it is a breaking change for current users

Name Description Parameters
input Triggers when carousel item value is changed value: Boolean, value: String
indicator-change Triggers when indicator-mode value is changed value: Boolean, value: String

Workaround

The current workaround (not tested yet) would be to update the v-model manually through @change event.

// Untested
<b-carousel @change="value => selected = value"></b-carousel>
@apolokaklab
Copy link
Contributor

@lunfel Hi, Actually that was intentional, so that I could make the b-carousel work with the b-carousel-list. for now you can use event @change like this

@jtommy jtommy removed the bug label Feb 16, 2020
@jtommy jtommy added this to To do in v1 Apr 8, 2020
@jtommy
Copy link
Member

jtommy commented Jun 26, 2020

Close #2619

@jtommy jtommy closed this as completed Jun 26, 2020
@jtommy jtommy moved this from To do to Done in v1 Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v1
  
Done
Development

No branches or pull requests

3 participants