Skip to content

Allow editing transaction amount after clicking max (#8475)#10278

Merged
Gudahtt merged 1 commit intoMetaMask:developfrom
adonesky1:8475-allow-editing-max-mode
Jan 27, 2021
Merged

Allow editing transaction amount after clicking max (#8475)#10278
Gudahtt merged 1 commit intoMetaMask:developfrom
adonesky1:8475-allow-editing-max-mode

Conversation

@adonesky1
Copy link
Copy Markdown
Contributor

Fixes: #8475

Explanation: Removes maxModeOn prop from UnitInput component which when true disabled the input. Per request on issue #8475, removing the maxModeOn flag allows users to edit currency input when transaction max button is selected.

Manual testing steps:

  • Enter send flow for Eth
  • Click Max
  • Edit on send amount input should be enabled

@adonesky1 adonesky1 requested a review from a team as a code owner January 25, 2021 02:00
@adonesky1 adonesky1 requested a review from danjm January 25, 2021 02:00
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 25, 2021

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@adonesky1
Copy link
Copy Markdown
Contributor Author

CLA Signature Action:

Thank you for your submission, we really appreciate it. We ask that you read and sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just by adding a comment to this pull request with this exact sentence:

I have read the CLA Document and I hereby sign the CLA

By commenting with the above message you are agreeing to the terms of the CLA. Your account will be recorded as agreeing to our CLA so you don't need to sign it again for future contributions to this repository.

0 out of 1 committers have signed the CLA.
@adonesky1

I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! There are a couple of tasks left to finishing this:

  • The prop maxModeOn is still being passed into currency-input.component from currency-input.contiainer. Could you removed this unusued prop from the container component?

  • Max mode remains toggled after the user edits the gas amount, which doesn't seem ideal. Ideally max mode would toggle when the user edited the gas amount, so that the user could click "Max" again and go back to the maximum amount. This is probably easiest to accomplish by editing this change handler.

Additionally, the CLA bot requires you to state that you agree to the CLA by making a comment with just that phrase. That last attempt didn't work because you included a quote of the CLA bot comment.

@adonesky1
Copy link
Copy Markdown
Contributor Author

Thanks for your feedback @Gudahtt!

Regarding this piece:

  • Max mode remains toggled after the user edits the gas amount, which doesn't seem ideal. Ideally max mode would toggle when the user edited the gas amount, so that the user could click "Max" again and go back to the maximum amount. This is probably easiest to accomplish by editing this change handler.

I'm completely new to this codebase so I could very well be missing something but won't the AdvancedGasInputs need to toggle off maxMode in their change handler(s) to produce the desired behavior you describe?

Thanks!

@adonesky1
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@Gudahtt
Copy link
Copy Markdown
Member

Gudahtt commented Jan 26, 2021

I'm completely new to this codebase so I could very well be missing something but won't the AdvancedGasInputs need to toggle off maxMode in their change handler(s) to produce the desired behavior you describe?

I was thinking of the amount field, not the gas fields. That's an interesting point though 🤔 Maybe it should toggle when gas is edited as well? I think we should leave it for now so that it matches the behaviour of the token send, but that's something worth considering in the upcoming confirmation screen redesign.

But about that request to update the change handler - sorry, you can disregard it completely! I just realized that maxMode is already being untoggled in that handler (via updateAmount), so the behaviour I requested is already present. My mistake.

So all that's left now is to get rid of the unused prop.

@adonesky1 adonesky1 force-pushed the 8475-allow-editing-max-mode branch from 131d4bc to 1d3b433 Compare January 26, 2021 22:13
@adonesky1 adonesky1 requested a review from Gudahtt January 26, 2021 22:14
@adonesky1 adonesky1 force-pushed the 8475-allow-editing-max-mode branch from 1d3b433 to 572fc3b Compare January 27, 2021 15:52
@Gudahtt
Copy link
Copy Markdown
Member

Gudahtt commented Jan 27, 2021

Almost there! The e2e tests can be tricky to debug, so I looked into this one. The last test failure is caused by an assertion in our e2e tests that (for some reason) ensures the input element is disabled. That line should be removed.

From line 311 of metamask-ui.spec.js:

assert.equal(await inputAmount.isEnabled(), false)

@adonesky1
Copy link
Copy Markdown
Contributor Author

Ah thanks @Gudahtt! Will do!

@adonesky1 adonesky1 force-pushed the 8475-allow-editing-max-mode branch from 572fc3b to a1a0747 Compare January 27, 2021 16:20
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great work! I've tested this, and it appears that this now works the same for ETH sends as it already did for token transfers. The amount can be freely edited after clicking max.

@Gudahtt Gudahtt merged commit 5696720 into MetaMask:develop Jan 27, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 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.

Allow editing transaction amount after clicking max

2 participants