Skip to content

Fix swipe action#1516

Merged
rayhomie merged 2 commits into
masterfrom
fix-swipe-action
Oct 21, 2025
Merged

Fix swipe action#1516
rayhomie merged 2 commits into
masterfrom
fix-swipe-action

Conversation

@rayhomie
Copy link
Copy Markdown
Collaborator

@rayhomie rayhomie commented Oct 21, 2025

Summary by CodeRabbit

发布说明

  • Bug Fixes

    • 改进滑动操作的状态重置逻辑,提升交互稳定性
  • Refactor

    • 重组复选框组件的模板结构
    • 重组单选框组件的模板结构,优化容器布局

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 21, 2025
@rayhomie rayhomie merged commit 351c899 into master Oct 21, 2025
18 checks passed
@rayhomie rayhomie deleted the fix-swipe-action branch October 21, 2025 03:20
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 21, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

概览

在 Checkbox 和 Radio 组件中将模板名称从 "checkbox-item" 和 "radio-item" 分别重命名为 "checkbox" 和 "radio",并更新相应的使用方式。SwipeAction 组件增强了触摸结束事件的状态重置逻辑。

变更表

模块 / 文件 变更摘要
Checkbox 模板重命名
src/Checkbox/index.axml
将模板 checkbox-item 重命名为 checkbox,更新模板结构,调整 onChange 事件绑定位置(从 WECHAT 移至 ALIPAY),更新所有模板使用引用
Radio 模板重命名
src/Radio/index.axml
将模板 radio-item 重命名为 radio,更新模板调用方式从 is="radio-item" 改为 is="radio",调整外层容器和内容插槽的结构
SwipeAction 状态管理增强
src/SwipeAction/index.ts
重新排序导入语句,扩展 onTouchEnd 事件处理器的状态重置逻辑,新增 swipedL 和 swipedR 标志位的重置操作

代码审查工作量评估

🎯 2 (简单) | ⏱️ ~12 分钟

变更主要为一致性的模板重命名和结构调整,虽涉及多个文件但改动模式相似且重复性强。SwipeAction 的状态重置扩展为独立的逻辑补充,无复杂依赖关系。

相关 PR

  • Fix swipe action #1511: 包含相同的代码级变更——checkbox-item→checkbox 和 radio-item→radio 模板重命名,以及 SwipeAction.onTouchEnd 的 swipedL/swipedR 重置逻辑

建议标签

bug

兔兔的庆祝诗

🐰 模板换新装,名字更妥当,
勾选和单选,结构更顺畅。
滑动事件稳,状态齐重置,
小兔来点赞,代码更精致! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-swipe-action

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff998c3 and 88e8133.

📒 Files selected for processing (3)
  • src/Checkbox/index.axml (2 hunks)
  • src/Radio/index.axml (2 hunks)
  • src/SwipeAction/index.ts (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @rayhomie, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily addresses a functional issue within the SwipeAction component by ensuring its internal swipe states are properly cleared upon user interaction completion, leading to more predictable behavior. Additionally, it includes a structural refactoring of the Checkbox and Radio components, streamlining their template definitions for improved modularity and separation of concerns.

Highlights

  • Swipe Action Fix: The SwipeAction component now correctly resets its swipe states (swipedL and swipedR) when a touch event is released, preventing unintended persistent swipe behavior.
  • Component Template Refactoring: The internal template structures for Checkbox and Radio components have been refactored. The core checkbox and radio templates now contain only the essential input elements, with the container and content slot logic moved to the main component's rendering.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 21, 2025

🎊 PR Preview 88e8133 has been successfully built and deployed to https://ant-design-ant-design-mini-preview-pr-1516.surge.sh

🕐 Build time: 308.524s

🤖 By surge-preview

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@dosubot dosubot Bot added the bug Something isn't working label Oct 21, 2025
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request modifies the Checkbox and Radio components to use a new template structure and updates the SwipeAction component to reset swipe states on touch end. The changes aim to improve code organization and fix a potential issue where swipe actions might not reset correctly.

Comment thread src/Checkbox/index.axml
Comment on lines +5 to 41
<template name="checkbox">
<view class="ant-checkbox-item-wrap">
<!-- #if WECHAT -->
<checkbox-group bindchange="onChange">
<checkbox
class="ant-checkbox-item-base"
value="{{ value }}"
onChange="onChange"
checked="{{ mixin.value }}"
disabled="{{ disabled }}" />
<!-- #endif -->
<view class="ant-checkbox-item-fake">
<view
class="ant-checkbox-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}"
style="{{ mixin.value && !disabled && color ? 'background:' + color : '' }}">
<ant-icon
a:if="{{ mixin.value }}"
type="CheckOutline"
className="ant-checkbox-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}-icon" />
</view>
</checkbox-group>
<!-- #endif -->
<!-- #if ALIPAY -->
<checkbox
class="ant-checkbox-item-base"
value="{{ value }}"
onChange="onChange"
checked="{{ mixin.value }}"
disabled="{{ disabled }}" />
<!-- #endif -->
<view class="ant-checkbox-item-fake">
<view
class="ant-checkbox-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}"
style="{{ mixin.value && !disabled && color ? 'background:' + color : '' }}">
<ant-icon
a:if="{{ mixin.value }}"
type="CheckOutline"
className="ant-checkbox-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}-icon" />
</view>
</view>
<view
class="ant-checkbox-item-content {{ disabled ? 'ant-checkbox-item-disabled' : '' }}">
<slot />
</view>
</view>
</template>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The template name has been changed from checkbox-item to checkbox. Ensure all references to this template are updated accordingly in other files to avoid breaking changes. This is a critical change that could break the component if not handled correctly.

<template name="checkbox-item">
  <view class="ant-checkbox-item-wrap">
    <!-- #if WECHAT -->
    <checkbox-group bindchange="onChange">
      <checkbox
        class="ant-checkbox-item-base"
        value="{{ value }}"
        checked="{{ mixin.value }}"
        disabled="{{ disabled }}" />
    </checkbox-group>
    <!-- #endif -->
    <!-- #if ALIPAY -->
    <checkbox
      class="ant-checkbox-item-base"
      value="{{ value }}"
      onChange="onChange"
      checked="{{ mixin.value }}"
      disabled="{{ disabled }}" />
    <!-- #endif -->
    <view class="ant-checkbox-item-fake">
      <view
        class="ant-checkbox-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}"
        style="{{ mixin.value && !disabled && color ? 'background:' + color : '' }}">
        <ant-icon
          a:if="{{ mixin.value }}"
          type="CheckOutline"
          className="ant-checkbox-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}-icon" />
      </view>
    </view>
  </view>
</template>

Comment thread src/Radio/index.axml
Comment on lines +5 to 39
<template name="radio">
<view class="ant-radio-item-wrap">
<!-- #if ALIPAY -->
<radio
value="{{ value }}"
class="ant-radio-item-base"
onChange="onChange"
checked="{{ mixin.value }}"
disabled="{{ disabled }}" />
<!-- #endif -->
<!-- #if WECHAT -->
<radio
value="{{ value }}"
class="ant-radio-item-base"
checked="{{ mixin.value }}"
disabled="{{ disabled }}" />
<!-- #endif -->
<view class="ant-radio-item-fake">
<view
class="ant-radio-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}"
style="{{ mixin.value && !disabled && color ? 'background:' + color : '' }}">
<ant-icon
a:if="{{ mixin.value }}"
type="CheckOutline"
className="ant-radio-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}-icon" />
</view>
</view>
<view
class="ant-radio-item-content {{ disabled ? 'ant-radio-item-disabled' : '' }}">
<slot />
</view>
</view>
</template>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The template name has been changed from radio-item to radio. Ensure all references to this template are updated accordingly in other files to avoid breaking changes. This is a critical change that could break the component if not handled correctly.

<template name="radio-item">
  <view class="ant-radio-item-container">
    <view class="ant-radio-item-wrap">
      <!-- #if ALIPAY -->
      <radio
        value="{{ value }}"
        class="ant-radio-item-base"
        onChange="onChange"
        checked="{{ mixin.value }}"
        disabled="{{ disabled }}" />
      <!-- #endif -->
      <!-- #if WECHAT -->
      <radio
        value="{{ value }}"
        class="ant-radio-item-base"
        checked="{{ mixin.value }}"
        disabled="{{ disabled }}" />
      <!-- #endif -->
      <view class="ant-radio-item-fake">
        <view
          class="ant-radio-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}"
          style="{{ mixin.value && !disabled && color ? 'background:' + color : '' }}">
          <ant-icon
            a:if="{{ mixin.value }}"
            type="CheckOutline"
            className="ant-radio-item-fake-{{ componentUtils.getClassName(mixin.value, disabled) }}-icon" />
        </view>
      </view>
    </view>
    <view
      class="ant-radio-item-content {{ disabled ? 'ant-radio-item-disabled' : '' }}">
      <slot />
    </view>
  </view>
</template>

Comment thread src/Checkbox/index.axml
Comment on lines +57 to 65
disabled,
color
}}"
/>
<view class="ant-checkbox-item-content {{ disabled ? 'ant-checkbox-item-disabled' : '' }}">
<slot />
</view>
</view>
</label>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The checkbox template is now wrapped inside ant-checkbox-item-container. This change affects the structure of the component. Verify that the styling and layout are still correct and that this change doesn't introduce any regressions. This structural change is significant and requires careful verification.

Comment thread src/Radio/index.axml
Comment on lines +50 to +58
is="radio"
data="{{
value,
mixin,
disabled,
color
}}"
/>
<view class="ant-radio-item-content {{ disabled ? 'ant-radio-item-disabled' : '' }}">
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The radio template is now wrapped inside ant-radio-item-container. This change affects the structure of the component. Verify that the styling and layout are still correct and that this change doesn't introduce any regressions. This structural change is significant and requires careful verification.

Comment thread src/SwipeAction/index.ts
this.onChangeEnd(e);
}
this.setData({ inTouch: false });
this.setData({ inTouch: false, swipedL: false, swipedR: false });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Adding swipedL: false, swipedR: false to the setData call in onTouchEnd ensures that the swipe action is fully reset when the touch ends. This prevents the component from remaining in a swiped state unintentionally. This is a critical fix for the swipe action's reliability.

Suggested change
this.setData({ inTouch: false, swipedL: false, swipedR: false });
this.setData({ inTouch: false });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant