Skip to content

fix: prevent blank screen when changing category in Unit Converter #31#34

Merged
me-shaon merged 3 commits intome-shaon:mainfrom
Krak3n909:fix/unit-converter-blank-screen
Apr 7, 2026
Merged

fix: prevent blank screen when changing category in Unit Converter #31#34
me-shaon merged 3 commits intome-shaon:mainfrom
Krak3n909:fix/unit-converter-blank-screen

Conversation

@Krak3n909
Copy link
Copy Markdown
Contributor

Description

Fixed a bug in the Unit Converter where changing the category would cause the entire app to show a blank screen.

Changes

  • Safely reset fromUnit and toUnit when the category changes
  • Added defensive checks and try/catch in the conversion logic
  • Used optional chaining to prevent runtime errors

This resolves the crash reported in #31.

Testing

  • Tested switching between Length, Weight, Temperature, and Data categories
  • No more blank screen
  • Swap units and normal conversions still work correctly

Closes #31

- Safely reset fromUnit/toUnit when category changes
- Added safety checks and try/catch
- Fixes me-shaon#31
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the robustness of the UnitConverter component by implementing safety checks for unit selection, wrapping conversion logic in a try-catch block, and utilizing optional chaining for unit display. Key feedback includes refactoring the result formatting logic to use an existing utility function to maintain DRY principles and adjusting the conditional rendering of unit names to prevent visual spacing issues when units are undefined.

Krak3n909 and others added 2 commits March 28, 2026 13:16
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Import formatResult from utils/unit-converter and replace the manual integer/decimal formatting with a single call to formatResult when setting the converted value. Also refactor the inline JSX output into separate concatenated expressions for clearer rendering. These changes centralize result formatting and clean up the component's display logic.
@Krak3n909 Krak3n909 closed this Mar 28, 2026
@Krak3n909 Krak3n909 reopened this Mar 28, 2026
@Krak3n909
Copy link
Copy Markdown
Contributor Author

Assalamualaikum @me-shaon vai,
Please review this PR when convenient.

@me-shaon me-shaon merged commit 88abfeb into me-shaon:main Apr 7, 2026
2 checks passed
@me-shaon
Copy link
Copy Markdown
Owner

me-shaon commented Apr 7, 2026

@Krak3n909 Thanks for the contribution.

@Krak3n909
Copy link
Copy Markdown
Contributor Author

Thanks for taking the time to review this PR, I appreciate it.

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.

In Unit Converter screen changing Category makes the app blank screen.

2 participants