rx.input(auto_complete=...): a bool is dropped by React, and a string raises a TypeError
维护者通常 2 天内回复
已经有一个关联 PR 被合并了。
- #7418 来自 @benedikt-bartscher —— 已合并
评估
调研方向
首先阅读 text_field.py 中的 TextFieldRoot,并将其 auto_complete 声明与父级 elements.Input 声明进行比较。检查相关的组件测试,或为 rx.input(auto_complete="off") 添加测试覆盖。完成标准是该字符串被接受,并渲染为 autoComplete:"off",符合 issue 中的预期行为。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
rx.input (TextFieldRoot) declares auto_complete: Var[bool], but the HTML autocomplete attribute takes a string ("on", "off", or autofill tokens such as "email"). Its parent elements.Input declares auto_complete: Var[str], and so does the generated stub for rx.input. As a result, neither form works:
rx.input(auto_complete=False) # renders autoComplete:false, which React drops
rx.input(auto_complete="off") # TypeError: Invalid var passed for prop TextFieldRoot.auto_complete, expected type <class 'bool'>, got value off of type <class 'str'>.
React 19 renders <input autoComplete={false}/> as a bare <input/> and warns "Received false for a non-boolean attribute autoComplete". It does the same for true; only strings reach the DOM. So the prop can't turn browser autocomplete off, and type checkers, which read the stub, accept only the strings that fail at runtime.
To Reproduce
import reflex as rx
rx.input(auto_complete="off") # TypeError
print(rx.input(auto_complete=False)) # jsx(RadixThemesTextField.Root,{autoComplete:false},)
Expected behavior
rx.input(auto_complete="off") renders autoComplete:"off", like rx.el.input(auto_complete="off") does.
Specifics (please complete the following information):
- Python Version: 3.14
- Reflex Version: main (0.9.13.dev,
text_field.pyunchanged since 0.9.12) - OS: Linux
- Browser (Optional): any; checked with
react-dom19.2.8'srenderToStaticMarkup
Additional context
The stub shows str because _extract_class_props_as_ast_nodes in the pyi generator walks the MRO base-first and keeps the first declaration of each prop. A subclass's override of a prop's type or doc therefore never reaches the stub: TextFieldRoot's default_value and max_length also show elements.Input's types. That's a separate bug, so I'm keeping it out of the fix for this one.
- 主要语言
- Python
- 星标
- 29k
- 派生
- 1.8k
- 平均合并
- 3 天 5 小时
- 30 天内合并 PR
- 187
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
reflex-dev/reflex 的其他 Issue
-
reflex run --frontend-only / --backend-only fails when rxconfig sets the ports可能已有人在做 @ybai08 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
reflex-dev/reflex#7686 · 1 条评论 ·
维护者通常 2 天内回复
-
Add a `SetVar` backed by the JS `Set` object可能已有人在做 @FarhanAliRaza 于 6 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
reflex-dev/reflex#7623 · 2 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
reflex-dev/reflex#7260 · 2 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
reflex-dev/reflex#7148 · 1 条评论 ·
维护者通常 2 天内回复
-
ClientStateVar: a component that mounts while the value is non-default never re-renders on the push back to the default可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
reflex-dev/reflex#6823 · 1 条评论 ·
维护者通常 2 天内回复
查看 reflex-dev/reflex 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
ComposioHQ/awesome-claude-skills#2398 ·
维护者通常 2 天内回复
-
bug converter
难度 2/5 1-3 小时 新手友好度 62/100
grafana/sigma-rule-deployment#435 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 73/100
datamodel-code-generator/datamodel-code-generator#5589 ·
维护者通常 1 天内回复
-
Shell: serve the home app's Cookie Policy on a hard reload可能已有人在做 @2001anshkaushik 今天认领。 未关闭feature module:ai
难度 2/5 1-3 小时 新手友好度 88/100
rocketride-org/rocketride-server#2899 · 1 条评论 ·
维护者通常 2 天内回复
-
GEFSv12
难度 2/5 1-3 小时 新手友好度 70/100