Skip to content

Fix hardware account selection#10198

Merged
Gudahtt merged 1 commit intodevelopfrom
fix-hardware-account-selection
Jan 18, 2021
Merged

Fix hardware account selection#10198
Gudahtt merged 1 commit intodevelopfrom
fix-hardware-account-selection

Conversation

@Gudahtt
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt commented Jan 15, 2021

Fixes #9244

When trying to connect a Trezor account on a fresh install of MetaMask, the radio buttons on the account selection page would not respond to being clicked.

When debugging this, it looks like the onChange event was never triggered. A radio <input> element should trigger onChange whenever the selection state change, but seemingly this wouldn't happen if the change in selection state was undone during the same render cycle. If I paused at a breakpoint during the render, I could see the checkbox get selected then unselected again without triggering onChange.

The simplest fix was to use onClick instead of onChange. This seems more appropriate anyway because we're treating the radio button as a controlled component here, so the state of the underlying element isn't really of any concern.

Fixes #9244

When trying to connect a Trezor account on a fresh install of MetaMask,
the radio buttons on the account selection page would not respond to
being clicked.

When debugging this, it looks like the `onChange` event was never
triggered. A radio `<input>` element should trigger `onChange` whenever
the selection state change, but seemingly this wouldn't happen if the
change in selection state was undone during the same render cycle. If
I paused at a breakpoint during the render, I could see the checkbox
get selected then unselected again without triggering `onChange`.

The simplest fix was to use `onClick` instead of `onChange`. This seems
more appropriate anyway because we're treating the radio button as a
controlled component here, so the state of the underlying element isn't
really of any concern.
@Gudahtt Gudahtt requested a review from a team as a code owner January 15, 2021 20:28
@Gudahtt Gudahtt requested a review from brad-decker January 15, 2021 20:28
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [4ed8096]
Page Load Metrics (510 ± 42 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint31634484
domContentLoaded3385895088742
load3395925108742
domInteractive3385885088742

@brad-decker
Copy link
Copy Markdown
Contributor

LGTM

@Gudahtt Gudahtt merged commit 87d181b into develop Jan 18, 2021
@Gudahtt Gudahtt deleted the fix-hardware-account-selection branch January 18, 2021 16:16
@github-actions github-actions bot locked and limited conversation to collaborators Jan 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metamask won’t select eth account

3 participants