Repository navigation
Closed
Labels
platform: learnUI side of the client application that needs familiarity with React, Gatsby etc.scope: UIThreads for addressing UX changes and improvements to user interfacestatus: PR in worksWork in Progress (WIP) Issues.
Description
Context
We are swapping out the Bootstrap's Button component for the ui-components one. The PR for this change is already created (#51443), but we would like to split the PR into smaller parts to ease the review process and to minimize the risk of introducing regression.
I'm opening this issue to track the PR series as well as to document issues I find during the work. The issue can be closed once all of the PRs are merged.
Goals
- Completely remove the usage of Bootstrap
Button - Ensure that the replacement doesn't introduce bugs
- Opportunistically remove the existing CSS overrides in /learn
- Adding CSS overrides may be unavoidable, but try to minimize them as the component library should already cover most of the use cases. The overrides should be accompanied with a code comment explaining the temporary state of the code.
High level approach
My plan is to split the change per page or section. Though since Button is also used in shared components, it's possible that we will have PRs that impact several pages/components. I'll see how my strategy works out as I dive in 😄
Tasks
ui-components
- [UI Components] Styling issues in Button component #52115
- Export the Button component for consumption (refactor(client): replace Bootstrap button component on Show Certification page #52204)
Learn
-
client/src/client-only-routes/show-certification.tsx(refactor(client): replace Bootstrap button component on Show Certification page #52204) -
client/src/client-only-routes/show-unsubscribed.tsx(refactor(client): replace button in unsubscribed and report user pages #52326) -
client/src/client-only-routes/show-user.tsx(refactor(client): replace button in unsubscribed and report user pages #52326) -
client/src/components/Donation/card-update-alert-handler.tsx(refactor(client): migrate Bootstrap components in update-stripe-card #52816) - Migrate Button component in donation form #52349
-
client/src/components/Donation/donate-completion.tsx -
client/src/components/Donation/donate-form.tsx -
client/src/components/Donation/donation-modal.tsx -
client/src/components/Donation/stripe-card-form.tsx
-
-
client/src/components/Header/components/login.tsx(refactor(client): replace Bootstrap button component on settings page #52525) -
components/helpers/form-
client/src/components/helpers/form/block-save-button.tsx(refactor(client): replace Bootstrap button component on settings page #52525) - Delete
client/src/components/helpers/toggle-button.css(refactor(client): replace Bootstrap button component on settings page #52525)
-
-
client/src/components/profile/components/time-line.tsx(refactor(client): replace Bootstrap button in modals and solution widget #52378) -
components/settings(refactor(client): replace Bootstrap button component on settings page #52525)-
client/src/components/settings/about.tsx -
client/src/components/settings/certification.tsx -
client/src/components/settings/danger-zone.tsx -
client/src/components/settings/delete-modal.tsx -
client/src/components/settings/email.tsx -
client/src/components/settings/honesty.test.tsx -
client/src/components/settings/honesty.tsx -
client/src/components/settings/internet.tsx -
client/src/components/settings/portfolio.tsx -
client/src/components/settings/privacy.tsx -
client/src/components/settings/reset-modal.tsx -
client/src/components/settings/toggle-button-setting.tsx -
client/src/components/settings/toggle-radio-setting.tsx -
client/src/components/settings/user-token.tsx(fix(client): remove react-bootstrap for user token widget #52340) -
client/src/components/settings/username.tsx
-
-
client/src/pages/update-email.tsx- this has to be done together with the settings page as there are CSS collision caused by the settings page's overrides (refactor(client): replace Bootstrap button component on settings page #52525) -
client/src/pages/email-sign-up.tsx(refactor(client): replace Bootstrap button in modals and solution widget #52378) - Modals and widgets (refactor(client): replace Bootstrap button in modals and solution widget #52378):
-
client/src/components/signout-modal/index.tsx -
client/src/components/staging-warning-modal/index.tsx -
client/src/components/solution-display-widget/index.tsx -
client/src/components/SolutionViewer/exam-results-modal.tsx -
client/src/components/SolutionViewer/project-modal.tsx
-
-
templates/Challenges-
client/src/templates/Challenges/classic/lower-jaw.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/codeally/show.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/components/completion-modal.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/components/help-modal.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/components/project-preview-modal.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/components/reset-modal.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/components/shortcuts-modal.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/components/tool-panel.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/dialogue/show.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/exam/components/exam-results.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/exam/components/exit-exam-modal.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/exam/components/finish-exam-modal.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/exam/components/foundational-c-sharp-survey.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/exam/components/foundational-c-sharp-survey-alert.tsx(fix(client): C# survey alert not showing in night mode #52339) -
client/src/templates/Challenges/exam/show.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/fill-in-the-blank/show.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/ms-trophy/link-ms-user.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/ms-trophy/show.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/odin/show.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/projects/tool-panel.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577) -
client/src/templates/Challenges/video/show.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577)
-
-
templates/Introduction-
client/src/templates/Introduction/components/cert-challenge.tsx(refactor(client): migrate Bootstrap button in challenge templates #52577)
-
Reacted by Shaun Hamilton, Ahmad Abdolsaheb, Sem Bauke and Mayank Kamboj
Metadata
Metadata
Assignees
Labels
platform: learnUI side of the client application that needs familiarity with React, Gatsby etc.scope: UIThreads for addressing UX changes and improvements to user interfacestatus: PR in worksWork in Progress (WIP) Issues.
Activity
Sboonny commentedon Dec 8, 2023
Hey @huyenltnguyen, which buttons that you haven't started yet, that I can take over?
huyenltnguyen commentedon Dec 9, 2023
I'm almost done with the code changes actually. and what has been taking so long is the regression testing (basically I need to check the display of each button, including all of its states) 🙂. I'll open the remaining PRs in a couple days.
huyenltnguyen commentedon Jan 30, 2024
Re-opening the issue as part of the migration was reverted (#53447).
ojeytonwilliams commentedon Jan 30, 2024
Thanks for reopening this, @huyenltnguyen.
So, the issue was that passing
hrefas a prop meant thatonClickwas ignored by the Button (and it became impossible to claim certifications).I'm looking into improving our test coverage. It needs to be crystal clear that something serious has gone wrong if this button stops working. That's not currently the case. Also, hopefully, TypeScript can help us here: it should be complaining if someone passes an incompatible set of props. I'll see what I can do!
ojeytonwilliams commentedon Jan 30, 2024
I'm a little unsure what the desired behaviour is.
onClickanddisabledshould be allowed on both types of buttons? Then the logic is: ifdownload,hrefortargetare passed to the Button, then show the Link component.Is that correct?
huyenltnguyen commentedon Jan 30, 2024
Hi @ojeytonwilliams, I sincerely apologize for the mess. I'll help look into the issue as well.
The rendering logic of this part of the codebase is quite complicated, and IMHO it is more complicated than it should be. We have some
onClicklogic in /learn determining whether theButtonshould behave like a link or an actual button, then under the hood, theButtoncomponent looks at thehrefprop to decide if an<a>or a<button>should be rendered.I agree. I checked the behavior again on
mainand after the revert, and found that the behavior I expected was wrong. And I, uhm, disabled Cypress tests because I trusted myself more (which resulted a show stopper). So the path forward here is to enable the tests and scrutinize the changes I made and ensuring the new PR should pass the tests.Yes, both of them are acceptable on both button types.
I'll need to re-check how the
Buttoncomponent handlesonClick. But ifdisabledistrue,Buttonwill:aria-disabledtotrue(we don't use thedisabledattribute due to it having some accessibility issue)<button>element, as a link (<a>) cannot be disabledWe only look for the truthiness of the
hrefvalue. If the value is truthy, we render an<a>; otherwise, we render a<button>.I think the issue came from these lines:
Notice the
voidoperator added to the function call. It was to resolve ESLint errors, but thevoidoperator evaluates the expression toundefined, regardless of the actual return value is, so I think it might have something to do with how the buttons behave.I'll try removing that and test things around.
ojeytonwilliams commentedon Jan 31, 2024
Thanks, I've not been following the UI Components development that closely, so I'll definitely need it. And don't worry about the bug - as a general rule, disabling tests for functionality that you're not deliberately removing is a bad idea, but that should have been caught in QA.
Great, thanks for confirming. That should make the types a little easier to manage.
Hmm. I'm pretty sure that
downloadandtargetdon't make sense forbuttonelements, so we should probably switch to usingaelements if any of them are truthy.