Skip to content

fix(core/views): disabled CheckBox still toggles checked state on click - #1503

Merged
elixxli merged 1 commit into
Tencent-TDS:mainfrom
Lfan-ke:feat/native-table-view
Jul 28, 2026
Merged

fix(core/views): disabled CheckBox still toggles checked state on click#1503
elixxli merged 1 commit into
Tencent-TDS:mainfrom
Lfan-ke:feat/native-table-view

Conversation

@Lfan-ke

@Lfan-ke Lfan-ke commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

A disabled CheckBoxView (when disable(true) is set) still responds to tap events: the click handler mutates checked, fires checkedDidChanged, and triggers a re-render, making the disabled state purely cosmetic.

Root cause

The click handler in body() has no guard against the disable flag:

event {
    click {
        ctx.attr.checked = !ctx.attr.checked  // fires regardless of disable
    }
}

Fix

Add an early return when the checkbox is disabled:

event {
    click {
        if (ctx.attr.disable) return@click
        ctx.attr.checked = !ctx.attr.checked
    }
}

Testing

Reproduce by placing a CheckBox with disable(true) and tapping it — checkedDidChanged should not fire after this fix.

@tencent-adm

tencent-adm commented Jul 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@KuiklyAI KuiklyAI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 KuiklyAI Code Review

基本信息

  • PR:#1503 · feat(core/views): add TableView, TableRowView, TableCellView native DSL
  • 作者:Lfan-ke (禾可) main ← feat/native-table-view

变更概述

  • 干了什么:在 core/ 新增 TableView.kt,定义了 TableView/TableRowView/TableCellView 三个原生表格 DSL 组件,继承自 GroupView,并在 ViewConst 中注册对应的原生视图名(KRTableView/KRTableRowView/KRTableCellView)。同时在 demo/ 中新增了 TableViewDemoPage 示例页面。
  • 解决什么:为 Kuikly 框架增加表格组件 DSL 层能力,closes #1479
  • 方案 & 合理性:DSL 层设计整体合理,遵循现有 GroupView/GroupAttr/GroupEvent 模式,与 DivView 的设计风格一致。isRenderView() = true 确保不参与 flat-layer 优化也符合表格视图需要独立原生实现的语义。

主要问题

1. 缺少原生渲染层实现TableView/TableRowView/TableCellViewviewName() 分别映射到 KRTableView/KRTableRowView/KRTableCellView,但所有 core-render-* 模块中均未找到对应原生实现。当前仅提供了 DSL 声明层,缺少至少一个平台的原生渲染器配合,功能无法端到端跑通。建议确认原生 renderer 是否在其他分支/仓库中,或者至少补一个平台的实现。

2. 缺少 API 文档docs/API/components/ 下没有 table.md,新增公开 DSL 组件需要同步补充组件文档(参考同级 list.mdscroll-picker.md 的格式)。

3. rowClick/rowLongPress 事件语义需明确 — 这两个事件定义在 TableEvent(table 级别),但 index 来自 native 数据。目前看起来是 table 级别代理 row 事件的设计,但如果 native 层传的是 row index,handler 能正确拿到;如果传错数据,(data as? Number)?.toInt() ?: 0 会静默 fallback 到 index=0,建议至少打个 warning log。

下面的 inline comment 是几个具体代码层面的建议。

Comment thread core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt Outdated
Comment thread core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt Outdated
Comment thread core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt Outdated
Comment thread core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt Outdated
@Lfan-ke
Lfan-ke force-pushed the feat/native-table-view branch from 9d1db9f to d443baa Compare July 7, 2026 09:02

@KuiklyAI KuiklyAI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 KuiklyAI Code Review(增量)

上一轮提出的 5 条 inline comment 均未在最新提交中处理,本轮无新提交,也无新增风险点。请作者确认上轮反馈是否接受,或说明不处理的理由。

已知未解决问题速览:

  • rowClick/rowLongPress?: 0 静默 fallback
  • selected/deselected 缺少 index 参数
  • TableCellEvent 空壳是否需要 cell 级事件
  • allowsSelectionDuringEditing 等属性缺失(低优先级)
  • Demo 中 TableItem 放在文件顶层

@Lfan-ke
Lfan-ke force-pushed the feat/native-table-view branch from d443baa to 8d51db4 Compare July 7, 2026 09:23

@KuiklyAI KuiklyAI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 KuiklyAI Code Review

基本信息

  • PR:#1503 · feat(core/views): add TableView, TableRowView, TableCellView native DSL
  • 作者:Lfan-ke
  • 分支:Lfan-ke/feat/native-table-view → Tencent-TDS:main

变更概述

  • 干了什么:在 core/ 中新增 TableViewTableRowViewTableCellView 三个表格组件,基于 GroupView 实现,映射到原生 KRTableView/KRTableRowView/KRTableCellView;新增对应的 TableAttr/TableRowAttr/TableCellAttr 属性和 TableEvent/TableRowEvent/TableCellEvent 事件;在 ViewConst 中注册了三个新 view type 常量;新增 demo 页面 TableViewDemoPage 展示一个学生成绩表格。
  • 解决什么:为实现跨平台原生表格组件提供 DSL 层的声明定义(closes #1479)。
  • 方案合理性:技术路径正确 — 复用现有的 GroupView/GroupAttr/GroupEvent 基础设施,保持了与 ListView、ScrollerView 等现有组件一致的模式。isRenderView() = true 的覆盖是为了阻止 flat-layer 优化,确保原生 Native 视图独立渲染,这个方向正确但注释需要补充说明原因。

⚠️ 需要关注的几个问题

  1. 缺少跨平台 native renderer 实现 — 当前 PR 只定义了 DSL 层声明(ViewConst + TableView.kt),但 core-render-android/core-render-ios/core-render-ohos/ 中都没有看到对应的 KRTableViewKRTableRowViewKRTableCellView 原生视图实现。如果没有对应的 render 层,这三类组件在运行时将无法正常工作。
  2. API 文档缺失 — 作为对外的公共 API,TableView、TableAttr、TableEvent 等建议补充 KDoc 注释,至少包括类级别说明和主要的可配置属性/事件含义。
  3. TableCellEvent 是空类 — 目前完全没有可监听的事件,虽然不影响编译但作为公共 API 显得有些冗余。如果未来有计划扩展可以保留,否则建议移除以简化 API 面。

Comment thread core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt Outdated
Comment thread core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt Outdated
Comment thread core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt Outdated
Comment thread core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt Outdated
@Lfan-ke
Lfan-ke force-pushed the feat/native-table-view branch from 8d51db4 to bd6e268 Compare July 7, 2026 14:10

@KuiklyAI KuiklyAI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 KuiklyAI Code Review(增量)

本轮 feat(core/views): add TableView, TableRowView, TableCellView native DSL. 更新修复了上一轮 review 的多项问题:

  • rowClick/rowLongPress fallback 路径加了 KLog.w 日志
  • selected/deselected handler 改为 (index: Int) -> Unit
  • isRenderView() 中文注释改为英文
  • ✅ demo 中展示了 selected/deselected 事件

遗留问题:

  • TableCellEvent 仍是空壳,Cell 是否需要独立事件入口建议后续评估
  • 顶层 TableRow()TableView.TableRow() 缺少 KDoc 区分说明
  • TableItem 作为 private data class 放在文件顶层,与现有 demo 风格不完全一致

新发现:selected/deselected 的异常数据错误处理与 rowClick/rowLongPress 不完全一致(后者有 KLog.w,前者直接 return@register)。已作为 inline comment 标注。

Comment thread core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt Outdated
@Lfan-ke
Lfan-ke force-pushed the feat/native-table-view branch from bd6e268 to 635dce5 Compare July 7, 2026 14:54

@KuiklyAI KuiklyAI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 KuiklyAI Code Review(增量)

上轮遗留的 KLog.w 一致性问题已修复 — TableRowEvent.selected/deselected 现在和 TableEvent.rowClick/rowLongPress 使用完全一致的空值校验 + 日志警告模式。当前代码在所有三个审查维度(功能正确性、代码质量、文档同步)上没有发现新增问题,整体代码质量良好。

变更概要:新增 TableView/TableRowView/TableCellView 自研 DSL,基于 GroupView 实现,支持 separatorColor/separatorHeight/allowsSelection 等表格属性,以及 rowClick/rowLongPress/selected/deselected 等事件,附带完整 Demo。

@elixxli

elixxli commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

e: file:///Volumes/data/workspace/core/src/commonMain/kotlin/com/tencent/kuikly/core/views/TableView.kt:143:22 Unresolved reference 'w'.
欢迎提交 犀牛鸟的题目可以以独立仓库的方式作答~

@Lfan-ke
Lfan-ke force-pushed the feat/native-table-view branch from 635dce5 to 6c8a2db Compare July 8, 2026 03:59

@KuiklyAI KuiklyAI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 KuiklyAI Code Review(增量)

上一轮 review 的 7 个问题已通过代码修改解决(事件 handler 签名统一、异常数据日志记录、注释英文化、demo 补充 selected/deselected 示例等),已通过 reply 确认。

剩余 4 条是建议性质的评论(TableCellEvent 空壳、TableRow 双重入口 KDoc、TableItem 位置、separator 命名风格),均属于可选改进项,不阻塞功能。

本轮 diff 无新增风险,代码质量良好,没有新的 inline comment 需要关注。

@Lfan-ke
Lfan-ke force-pushed the feat/native-table-view branch from 6c8a2db to 8021d64 Compare July 8, 2026 15:09
@Lfan-ke Lfan-ke changed the title feat(core/views): add TableView, TableRowView, TableCellView native DSL fix(core/views): disabled CheckBox still toggles checked state on click Jul 8, 2026
@Lfan-ke

Lfan-ke commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

感谢 @elixxli 提醒!

关于犀牛鸟的三个选题(图表组件、表格组件、加载框组件),已分别以独立仓库方式提交并在对应 issue 回复:

本 PR 已经改为一个独立的 bug fix:CheckBoxViewdisable(true) 时点击仍会触发 checked 切换,与犀牛鸟题目无关。当前 PR diff 仅修改 CheckBoxView.kt(一行 guard,不想留closed非merged的黑历史...)。如有疑问欢迎指出,感谢!

@elixxli

elixxli commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

欢迎pr,disable后也不应该响应click,click会有system提示音的,可以在整层注册 touchEnable(!ctx.attr.disable) 控制是否可触摸。

Signed-off-by: 林晨 (Leo Cheng) <leo-cheng@vip.qq.com>
@Lfan-ke
Lfan-ke force-pushed the feat/native-table-view branch from 8021d64 to 907132f Compare July 13, 2026 13:30
@Lfan-ke

Lfan-ke commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

感谢 @elixxli 的建议!已按照建议改用 touchEnable(!ctx.attr.disable) 方案,在整层屏蔽触摸事件,这样 disabled 状态下系统点击音效也不会触发。

@iPel iPel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@elixxli
elixxli merged commit 2feaa2c into Tencent-TDS:main Jul 28, 2026
4 checks passed
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.

5 participants