
Design comparison
Solution retrospective
Built with. 🔨
- HTML & CSS.
- TypeScript.
- Zod - Form validation.
- Vite.
Bugs. 🐛
- There is currently a bug where, if a user enters an invalid input (such as a negative number) as the custom tip and then selects an option from the provided tip radio buttons without correcting the invalid input, the error message does not disappear.
-
I visually hid the radio buttons, and styled the labels to look like the radio buttons. Based on the radio button’s checked or focused state, the label will be styled. I had done this before so i already had some experience with this.
-
The tricky part was the 6th radio button, which technically doesn’t look like a radio button at all but rather an input where the user can input numbers. But in reality this too should be a radio button. Because if the 6th input is selected, any current selection on the other 5 radio buttons should be unchecked and if one of those radio buttons were checked then the 6th input should be unchecked. The solution was to have a radio button and as well as an
input type="number"
. The radio was visually hidden. The number input is what a user who uses their mouse clicks on. The radio button is what a keyboard user will focus on. So when the mouse click happened on the number input, the radio button needed to be checked. When a keyboard moved the focus to the radio button and made it checked, the number input should receive focus so that the user can actually type into the input field.customInput.addEventListener("focus", () => { customRadioButton.checked = true }) customRadioButton.addEventListener("change", () => { customInput?.focus() })
-
You can use
formElement.reset()
to reset the form inputs to their default values, including unchecking checked radio buttons or checkboxes. I used to do this manually by assigning empty strings to inputs.
Any sort of feedback is appreciated!
Community feedback
- @mahmoudAcmPosted 4 months ago
Great job completing the challenge! I noticed something about the number input field—the up and down arrows (spinners). It might improve the user experience if these were hidden or replaced with a custom solution. For example, you could add your own increment/decrement buttons or a more tailored approach that fits the design.
1@DarkstarXDDPosted 4 months ago@mahmoudAcm Hey thanks for the feedback! Yeah true, custom styled spinners would actually look much more nicer. Something to work on if i come back to this project again.
1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord