Skip to content

fix(docs): keep converter forms usable after submitting - #65

Open
igorgbr wants to merge 1 commit into
ArjunSharda:mainfrom
igorgbr:fix/converter-form-submit
Open

fix(docs): keep converter forms usable after submitting#65
igorgbr wants to merge 1 commit into
ArjunSharda:mainfrom
igorgbr:fix/converter-form-submit

Conversation

@igorgbr

@igorgbr igorgbr commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Closes #64

Problem: as described in the issue, the three converter pages had two defects
that masked each other. The submit buttons had no type, so they defaulted to
type="submit"; and the handlers wrote their result into the <form> element
itself, wiping out the input and button after a single conversion.

Fix: added type="button" to the three converter buttons, and gave each page
a dedicated <p> for the result so the form survives. In
lookuptimezonetime.html an invalid timezone or locale made toLocaleString
throw — which is what exposed the submit defect — so that case now reports
"Invalid Date" instead of failing silently.

On the asymmetry between the three files: each page already handled errors
differently before this PR (utcsecondstodatetime.html checks for empty input,
datetimetoutc.html relies on toUTCString() returning "Invalid Date"). I kept
those as they were and only added handling where something was actually broken,
to keep the diff focused. Happy to unify them if you'd prefer.

Tested locally on all three converters: repeated conversions without a
reload, empty input, invalid date, and invalid timezone. No page reloads and no
query strings appended in any case.

image image image

The submit buttons had no type, so they defaulted to type=submit and
reloaded the page whenever the handler threw before writing its result.
The handlers also wrote into the <form> element itself, replacing the
input and button with the result text after a single conversion.

Add type="button" to the three converter buttons and write results into
a dedicated element. Also report invalid timezones and locales in
lookuptimezonetime.html instead of failing silently.

Closes ArjunSharda#64
@igorgbr
igorgbr requested a review from ArjunSharda as a code owner August 17, 2026 19:50
@igorgbr

igorgbr commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

The Lint Code Base failures are the same pre-existing ones as #63 I ran htmlhint and prettier against main and against this branch and the output is identical, 4 htmlhint errors in the same 2 files either way. They come from markup this PR doesn't touch: a stray > in </li>> at datetimetoutc.html:30, unbalanced </div>s in the same file (which makes prettier fail to parse it entirely), and a missing <!DOCTYPE html> in lookuptimezonetime.html. The line numbers only shifted by one, from the <p> this PR adds.

Dependency Review (the required check) passes, and TimeConv Welcomer fails on actions/first-interaction@v3 as before.

Those three markup issues are small and worth fixing — I can open a separate PR for them, plus the prettier --write pass I mentioned in #63, whenever you'd like. Kept them out of here to leave this diff focused on the converter bug.

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.

Converters break after one use: submit button reloads the page and the result overwrites the form

1 participant