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

fix(segmented): unable to switch again when the switch is rejected #8052

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

humandetail
Copy link

When the switch does not meet some business conditions and is rejected (the value does not change), the input radio is actually marked as checked internally, and clicking the switch again cannot trigger the change event.

Here is an example:

<template>
  <a-segmented :value="value" :options="data" @change="handleChange" />
</template>

<script lang="ts" setup>
import { reactive, ref } from 'vue';
import { Modal } from 'ant-design-vue';
const data = reactive(['Daily', 'Weekly', 'Monthly', 'Quarterly', 'Yearly']);
const value = ref(data[0]);
const confirm = () => {
  return new Promise(resolve => {
    Modal.confirm({
      title: 'Confirm',
      content: 'Are you sure you want to confirm?',
      onOk: () => {
        resolve(true);
      },
      onCancel: () => {
        resolve(false);
      },
    });
  });
};
const handleChange = v => {
  confirm().then(res => {
    if (res) {
      value.value = v;
    } else {
      console.log('reject');
    }
  });
};
</script>

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

Successfully merging this pull request may close these issues.

1 participant