Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

databinding组件二次打开时,无法正确获取上次设置的值 #11126

Open
franckchen opened this issue Oct 28, 2024 · 1 comment
Open
Labels
bug Something isn't working need confirm

Comments

@franckchen
Copy link
Contributor

描述问题:

databinding组件二次打开时,无法正确获取上次设置的值

截图或视频:

如何复现(请务必完整填写下面内容):

  • 一个Editor Plugin要帮助amis的组件实现数据绑定。 在plugin中,实现getAvailableContextFields方法。方法实现如下

image

  • data-binding-select 组件实现, 如下图

    选择后, 调用注入的onSelect方法设置绑定值, 注意值的类型是string

image

  • 绑定生效, 代码和右侧panel组件均可见到效果

    在没有关闭选择器的情况下, 选择后, react props取到的value值有效, 可以看到选择的值背景色已经变为红色。

image

  • 代码和右侧panel值均成功更新, 证明数据绑定有效

image

  • (问题出现!) 再次打开选择器后, 无法获取之前选择的值(选中项背景色未变为红色)

image (1)

  • 通过react devtool 查看各层组件value值均正确

image

image (1)

  • (问题分析) 渲染中,向自定义的数据绑定传递数据时, 输入的是value.value, 此时value的类型为string , value.value为undefined.最终二次打开选择组件时, 无法正常恢复上次渲染结果。value和result的值均正确(类型为string)。 value.value为undefined.

image (2)

  • 如回传选择值是调整为其他类型结构, 不生效. 应该是bug

image (3)

image (4)

Copy link

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

@github-actions github-actions bot added the bug Something isn't working label Oct 28, 2024
2betop pushed a commit that referenced this issue Oct 30, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working need confirm
Projects
None yet
Development

No branches or pull requests

1 participant