Skip to content

Conversation

@fcasibu
Copy link

@fcasibu fcasibu commented Dec 25, 2025

Description

Refactor frontend/ts/modals/* to replace jQuery (some still TODO). I've also modified dom.ts to add setValue for ElementsWithUtils<ElementWithValue> instance. Still trying to grep the whole flow/codebase, so usage of qsr or qs is uncertain (Probably use qsr always? Can find non-existing elements that way or developer error)

While doing the refactor, also stumbled upon things that I have questions for (didn't made any changes to them), which I thought can be improved:

  • custom-generator.ts:146: The user is able to write minLength > maxLength. Is this behavior correct?
  • custom-test-duration.ts:99: It seems like parseInput, always expects a non nullable string, and we seem to always expect that #customTestDurationModal input to always exist (so I used qsr), which makes the conditions val !== null, !isNaN(val) seem to be unnecessary (val is never null or NaN, tbh also isFinite, and val >= 0 is the only valid condition)
  • custom-text.ts:169: These elements does not seem exist .randomWordsCheckbox, .replaceNewlineWithSpace, .typographyCheck, and .delimiterCheck (last two is just in a challenge file). Are they good to remove?
  • edit-preset.ts:146: Noticed that we're not updaitng the DOM, since for the most part, in the logic, we mostly use state.checkboxes, so no problem happens, but I think it is also a good idea to update the DOM to match current state? Either calling updateUI() here or just changing the checked value inline.

Checks

  • Adding/modifying Typescript code?
    • I have used qs, qsa or qsr instead of JQuery selectors.
  • Check if any open issues are related to this PR; if so, be sure to tag them below.
  • Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info)
  • Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title.

Related #7186

@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Dec 25, 2025
@fcasibu fcasibu force-pushed the refactor/ts-modals-remove-jquery branch from e92798c to d0997c2 Compare December 25, 2025 12:18
const action = qsr("#editPresetModal .modal").getAttribute("data-action");
const propPresetName = qsa<HTMLInputElement>(
"#editPresetModal .modal input",
)[0]?.getValue() as string;
Copy link
Author

Choose a reason for hiding this comment

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

Can likely just query for a specific selector, but uncertain. Same for line 237

@fcasibu fcasibu force-pushed the refactor/ts-modals-remove-jquery branch from 1f2d152 to c45226a Compare December 25, 2025 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants