Change from `null` to `undefined` introduces issues with `<value> !== undefined`

Đang mở
#673 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Start with the TextField.tsx line linked in the issue, then follow the investigation in the linked comment and check Modal, Popover, Grid, and GridSpan, especially generateResponsiveCustomProperties. Review how each prop handles null and undefined, and decide whether defaulted props support null or need documentation. Done means resolving the listed checks and documenting the behavior decision.

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

Mô tả

bug

This is caused by https://github.com/react-ui-org/react-ui/issues/662


As result of mentioned change, TextField is incorrectly setting hasRootSmallInput class when inputSize is set to null. This is happening on following line: https://github.com/react-ui-org/react-ui/blob/71b2fe1cd5719128ebdf3d17b90f4b441ebe199d/src/components/TextField/TextField.tsx#L38

Problem is that if inputSize is set to null:

const hasSmallInput = (inputSize !== undefined) && (inputSize <= SMALL_INPUT_SIZE);

Then hasSmallInput is true because of inputSize <= SMALL_INPUT_SIZE => true. Why? Because null <= 10 ...

We need to investigate this and examine all occurrences of !== undefined and !== null as well. This is why I always recommend using != null to cover both cases.

Scope

Investigated in https://github.com/react-ui-org/react-ui/issues/673#issuecomment-5998585636.

  • Use != null in TextField, Modal and Popover (caused by #662)
  • Use prop == null in generateResponsiveCustomProperties (Grid, GridSpan)
  • Decide whether null is supported for props with defaults (Popover placement, tag, …), or document that only undefined means "not set"
Ngôn ngữ chính
TypeScript
Star
23
Fork
10
Merge trung bình
5 ngày 12 giờ
Pull request đã merge (30 ngày)
9

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

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

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 react-ui-org/react-ui

Tất cả issue của react-ui-org/react-ui

Issue tương tự

Thêm issue về TypeScript

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.