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

[p5.js 2.0+ Bug Report]: createRadio().disable(false) does not re-enable radio inputs

未关闭 适合新手
#9,316 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从 src/dom/dom.js 中的 self.disable 开始,issue 指出它会为每个单选输入设置 disabled 属性。检查是否已有覆盖 createRadio().disable() 的测试,并运行相关的 DOM 测试。当 disable(false) 移除每个单选输入的禁用状态,同时 disable(true) 仍会禁用它们时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Area:DOM Good First Issue p5.js 2.0+
Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

2.3.4

Web browser and version

firefox 157.0

Operating system

fedora

Steps to reproduce
  1. Open the p5.js Web Editor and select p5.js 2.3.4.
  2. Replace the sketch with the code below and run it.
  3. Wait one second for radio.disable(false) to execute.
  4. Observe that the radio buttons remain disabled and the status text reports Still disabled? true.
Expected behavior

Calling radio.disable(false) should re-enable the radio inputs, allowing the user to select an option again.

Actual behavior

The radio inputs remain disabled after radio.disable(false) is called.
The console shows that both inputs still have disabled === true, and their disabled attributes remain present with the string value "false".

Snippet
let radio;
let statusText;

function setup() {
  createCanvas(400, 120);

  radio = createRadio();
  radio.option('red');
  radio.option('blue');
  radio.position(20, 40);

  statusText = createP('Disabling radio buttons...');
  statusText.position(20, 65);

  radio.disable(true);

  setTimeout(() => {
    radio.disable(false);

    const inputs = radio._getOptionsArray();
    const stillDisabled = inputs.every(input => input.disabled);

    statusText.html(
      'Called disable(false). Still disabled? ' + stillDisabled
    );

    console.log(
      'Disabled properties:',
      inputs.map(input => input.disabled)
    );

    console.log(
      'Disabled attributes:',
      inputs.map(input => input.getAttribute('disabled'))
    );
  }, 1000);
}

function draw() {
  background(240);
}
Screenshot

p5.js Web Editor reproduction showing radio buttons remaining disabled after calling disable(false)

Additional context

The behavior appears to be caused by setting the HTML disabled attribute to a boolean value rather than updating the input's disabled state. HTML boolean attributes are enabled by their presence, regardless of the string value assigned to them.

The relevant implementation is in src/dom/dom.js, in self.disable, which iterates over the radio inputs and calls radioInput.setAttribute('disabled', shouldDisable).

A possible fix is to assign radioInput.disabled = shouldDisable, or otherwise remove the attribute when shouldDisable is false.

The reproduction was tested in the p5.js Web Editor using p5.js 2.3.4.

主要语言
JavaScript
星标
24.2k
派生
3.9k
平均合并
3 天 3 小时
30 天内合并 PR
34

环境准备

从这里开始

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

processing/p5.js 的其他 Issue

查看 processing/p5.js 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

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