Skip to content

fix: guard PageControl against missing onPageChange and make disabled actually disable dots - #5434

Open
zigzagdev wants to merge 1 commit into
uber:mainfrom
zigzagdev:fix/page-control-disabled-and-crash
Open

zigzagdev wants to merge 1 commit into
uber:mainfrom
zigzagdev:fix/page-control-disabled-and-crash

Conversation

@zigzagdev

Copy link
Copy Markdown
Contributor

Motivation

PageControl had two crash and functional break level issues living in the same handful of lines.

First, clicking a dot called onPageChange unconditionally even though the prop is typed optional, so any consumer that omits it (which the type explicitly allows) gets a runtime TypeError on the very first click.
Second, setting disabled only dimmed the dot's background color through a style prop; the underlying native radio input never received the disabled attribute, so a "disabled" PageControl stayed fully clickable and kept firing onPageChange, defeating the entire point of the prop.

Both bugs sit in the same render path, so fixing them together avoids touching this file twice.

Description

Changed the dot's onChange handler to call onPageChange with optional chaining so a missing handler is a no-op instead of a crash.
Added disabled={disabled} to the underlying radio input so the native disabled attribute is actually applied, which blocks both pointer and keyboard interaction and the onChange it was firing.
Added three regression tests covering the crash case, the disabled case, and the normal enabled click case, since PageControl previously had no test coverage at all.

Scope

Patch (Bug Fix)

… actually disable dots

onChange called onPageChange unconditionally even though it's typed
optional, throwing when a consumer omits it. disabled only dimmed the
dot's color via $disabled; the native radio input never got the disabled
attribute, so a "disabled" PageControl was still fully clickable and kept
firing onPageChange.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant