Skip to content
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

Fix dark mode slider #240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ShubhankarKG
Copy link
Contributor

Fixes #221

Changes done:

✅️ By submitting this PR, I have verified the following

  • Checked to see if a similar PR has already been opened 🤔️
  • Reviewed the contributing guidelines 🔍️
  • Sample preview link added (add a link from the checks tab after checks complete)
  • Tried Squashing the commits into one

@ShubhankarKG
Copy link
Contributor Author

This solves the problem but is a bit slow.
Preview link :- https://deploy-preview-240--wizardly-perlman-2ed351.netlify.app/#/

@YashKumarVerma
Copy link
Member

This solves the problem but is a bit slow.
Preview link :- https://deploy-preview-240--wizardly-perlman-2ed351.netlify.app/#/

How about using the method used for https://learn.circuitverse.org/

@ShubhankarKG
Copy link
Contributor Author

Probably can use that as well. @animesh-007 would you work on this one ? I'll tell you what the problem is :-

We run a function in the window.onLoad part of the script. That's where the problem lies. There's a chunk of code that assigns a ref in case darkmode is already enabled in localStorage. So, sometimes, that chunk of code gives an error, that causes the slider to move back. I'll also tag the exact line of code that does this. If you can bypass it, then it'll work.

show = !show;
document.querySelector("input[type='checkbox']").checked = true;
console.log(document.querySelector("input[type='checkbox']"))
document.querySelector("input[type='checkbox']").checked = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I placed this console.log deliberately here. If you open up your console, switch to dark mode and refresh, sometimes you'll see the proper input, and sometimes you'll see null. This null is the source cause of error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I placed this console.log deliberately here. If you open up your console, switch to dark mode and refresh, sometimes you'll see the proper input, and sometimes you'll see null. This null is the source cause of error.

@animesh-007 , here.

@animesh-007
Copy link
Contributor

Probably can use that as well. @animesh-007 would you work on this one ? I'll tell you what the problem is :-

We run a function in the window.onLoad part of the script. That's where the problem lies. There's a chunk of code that assigns a ref in case darkmode is already enabled in localStorage. So, sometimes, that chunk of code gives an error, that causes the slider to move back. I'll also tag the exact line of code that does this. If you can bypass it, then it'll work.

Ok I will try to solve it just tag me exact lines.

@Shivansh2407
Copy link
Member

@ShubhankarKG @animesh-007 are you working on this?

@ShubhankarKG
Copy link
Contributor Author

I mean, this current version is just a tad slow. This works perfectly well after a time interval.

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.

Dark mode gets switched off after refreshing the page
4 participants