Skip to content

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

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

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>

Copy link

github-actions bot commented May 7, 2025

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant