Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#9,316 4 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
html, javascript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu với self.disable trong src/dom/dom.js, nơi issue cho biết thuộc tính disabled được đặt trên từng radio input. Kiểm tra xem đã có bài kiểm thử nào bao phủ createRadio().disable() chưa và chạy các bài kiểm thử DOM liên quan. Công việc hoàn tất khi disable(false) xóa trạng thái bị vô hiệu hóa khỏi mọi radio input, còn disable(true) vẫn vô hiệu hóa chúng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
JavaScript
Star
24.2k
Fork
3.9k
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
35

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của processing/p5.js

Tất cả issue của processing/p5.js

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.