Skip to content

Commit b7fa3fa

Browse files
fix: Add default value to custom nonce modal (#28659)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** See original bug ticket. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28659?quickstart=1) ## **Related issues** Fixes: #28033 ## **Manual testing steps** See original bug ticket. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 2c9f8c2 commit b7fa3fa

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

ui/components/app/modals/customize-nonce/__snapshots__/customize-nonce.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ exports[`Customize Nonce should match snapshot 1`] = `
8686
min="0"
8787
placeholder="1"
8888
type="number"
89-
value=""
89+
value="1"
9090
/>
9191
</div>
9292
</div>

ui/components/app/modals/customize-nonce/customize-nonce.component.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ const CustomizeNonce = ({
2727
updateCustomNonce,
2828
getNextNonce,
2929
}) => {
30-
const [customNonce, setCustomNonce] = useState('');
30+
const defaultNonce =
31+
customNonceValue || (typeof nextNonce === 'number' && nextNonce.toString());
32+
const [customNonce, setCustomNonce] = useState(defaultNonce);
3133
const t = useI18nContext();
3234

3335
return (
@@ -107,10 +109,7 @@ const CustomizeNonce = ({
107109
type="number"
108110
data-testid="custom-nonce-input"
109111
min="0"
110-
placeholder={
111-
customNonceValue ||
112-
(typeof nextNonce === 'number' && nextNonce.toString())
113-
}
112+
placeholder={defaultNonce}
114113
onChange={(e) => {
115114
setCustomNonce(e.target.value);
116115
}}

0 commit comments

Comments
 (0)