Skip to content

fix: preserve input when swap fails - #261

Merged
anurag629 merged 1 commit into
codercops:developfrom
piyusshhjangid:fix/252-preserve-input-on-swap
Oct 22, 2026
Merged

anurag629 merged 1 commit into
codercops:developfrom
piyusshhjangid:fix/252-preserve-input-on-swap

Conversation

@piyusshhjangid

Copy link
Copy Markdown
Contributor

Closes #252

Summary

Prevent Swap from clearing user input after a failed URL or Base64 text conversion.

Changes

  • Disable the Swap button when there’s an error or no output.
  • Guard both swap handlers so the URL command palette and Base64 keyboard shortcut also preserve the input.
  • Add tests covering errors, empty output, and valid results for both tools.

How I tested this

  • npm run lint
  • npm run test
  • npm run build

AI assistance

OpenAI Codex helped implement the fix, add tests, and run verification.

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @piyusshhjangid, the fix itself is the right one: the check is in swap and the button is disabled. Two things before I can merge:

  1. The branch starts from an old develop (b3d036d, from #188), so it conflicts now. Since then #227 set up component tests, and #236 and #242 changed the URL encoder's switch, so please rebase on the current develop.
  2. develop already runs component tests with happy-dom (app/**/*.test.tsx, from #227), so the vitest.config.ts change and the two new .test.ts files aren't needed. Please put the tests in the existing TextTab.test.tsx and UrlEncoderClient.test.tsx and render the component, like the paste tests there: with an error showing, Swap is disabled and the Base64 shortcut doesn't clear the input, and a valid result still swaps. The canSwap tests only check the helper, so they'd still pass if the button or the shortcut lost the check.

@piyusshhjangid
piyusshhjangid force-pushed the fix/252-preserve-input-on-swap branch from 8d87c47 to 1e9ebe1 Compare October 22, 2026 11:43
@piyusshhjangid

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I rebased onto the latest develop, removed the redundant Vitest config change, and moved the regression tests into the existing component test suites. They now render each tool and verify that errors preserve the input through the URL swap command and Base64 shortcut, while valid results still swap. I’ve pushed the update to this PR.

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @piyusshhjangid, that's it. Lint, the 598 tests, the build and the page check pass on top of develop, and both new component tests fail with develop's components, where the Base64 shortcut and the URL encoder's command still clear the input.

@anurag629 anurag629 added the hacktoberfest-accepted PR counts for Hacktoberfest label Oct 22, 2026
@anurag629
anurag629 merged commit 5ad091d into codercops:develop Oct 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted PR counts for Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swap clears your input when the conversion shows an error (URL encoder and Base64 text)

2 participants