Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

rx.input(auto_complete=...): a bool is dropped by React, and a string raises a TypeError

已关闭 适合新手
#7,417 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

已经有一个关联 PR 被合并了。

  • #7418 来自 @benedikt-bartscher —— 已合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, react
领域
frontend

调研方向

首先阅读 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.py unchanged since 0.9.12)
  • OS: Linux
  • Browser (Optional): any; checked with react-dom 19.2.8's renderToStaticMarkup

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

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

reflex-dev/reflex 的其他 Issue

查看 reflex-dev/reflex 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。