-
-
Notifications
You must be signed in to change notification settings - Fork 3k
refactor(modals): remove jquery in ts/modals (@fcasibu) #7292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(modals): remove jquery in ts/modals (@fcasibu) #7292
Conversation
e92798c to
d0997c2
Compare
c45226a to
83a24cb
Compare
83a24cb to
e2f2cc7
Compare
Also fixes bugs added in monkeytypegame#7303
|
Not sure what's with this |
Ill help you out here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
frontend/src/ts/modals/streak-hour-offset.ts:42
- The
state.offsetis no longer being updated since the refactor removedsetStateToInput()and related functions. This function always uses the initial value of 0 fromstate.offsetinstead of reading from the input element. Change toconst inputValue = parseInt(modal.getModal().qs<HTMLInputElement>('input')?.getValue() ?? '0', 10);to read the current input value.
const inputValue = state.offset;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Some more comments for you to address |
|
Thanks for the help @Miodec! Done with the fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
frontend/src/ts/modals/streak-hour-offset.ts:42
- The
updatePreviewfunction reads fromstate.offset, but this value is never updated after the refactor removedsetStateToInput()and related logic. The function should read the offset value directly from the input element instead. Change line 42 to:const inputValue = parseInt(modal.getModal().qs<HTMLInputElement>(\"input\")?.getValue() ?? \"0\", 10);
function updatePreview(): void {
const inputValue = state.offset;
frontend/src/ts/modals/streak-hour-offset.ts:13
- The
stateobject is no longer used after the refactor and should be removed entirely.
let state = {
offset: 0,
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks! |
Description
Refactor
frontend/ts/modals/*to replace jQuery (some still TODO). I've also modifieddom.tsto addsetValueforElementsWithUtils<ElementWithValue>instance. Still trying to grep the whole flow/codebase, so usage ofqsrorqsis uncertain (Probably useqsralways? Can find non-existing elements that way or developer error). There are a lot of atomic commits in this PR, feel free to squash.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 likeparseInput, always expects a non nullable string, and we seem to always expect that#customTestDurationModal inputto always exist (so I usedqsr), which makes the conditionsval !== 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 usestate.checkboxes, so no problem happens, but I think it is also a good idea to update the DOM to match current state? Either callingupdateUI()here or just changing the checked value inline.quote-rate.ts:89:getQuoteStatsexpects aquotebut we're not really passing anything to it, so this essentially does nothing, since it returns immediately on!quoteChecks
qs,qsaorqsrinstead of JQuery selectors.Related #7186
#7186