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 Quiz expanding between questions #2184
Conversation
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.
Hi @itsyme, thanks for the work on this!
I think the reason why the things in Quiz.spec.js.snap
is being deleted is because it hasn't rendered yet after the triggers are triggered. I added await quizTimeOut()
to lines 198 and 237 in Quiz.spec.js and it seems to work.
Also I was wondering how did you get 525 for the value of delay?
Thanks @yucheng11122017! I got 525 by experimenting. I tried using 500 since the transitions were 0.5s long under |
Thank you for the feedback! I added |
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.
There are some flickering issues introduced by this change.
Presumably because the timeout is timed to be slightly after the transition actually ends.
Consider trying:
-
something better guaranteed https://developer.mozilla.org/en-US/docs/Web/API/Element/transitionend_event (what Vue internally uses also actually)
-
if that alone dosen't work.. (i have no time to browse the spec to check if the new card is introduced right before or after the transition ends...) consider if you really want to be attaching the new card only after the transition of the previous card has finished. (I am personally fine with this, though this changes the UX)
I believe there are just 2 main cases to consider:
- New card's height > old card's height
- Old card's height > new card's height
What can you do in these scenarios?
The implementation details should be clear after.
// Function to delay test until question is rendered | ||
export default function quizTimeout() { | ||
// eslint-disable-next-line no-promise-executor-return | ||
return new Promise(resolve => setTimeout(resolve, 525)); |
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.
Timeouts are an easy fix to many issues at first glance but we are making assumptions on browser internals and user device capabilities that are never guaranteed.
(Not to say they should never be used.. there are certainly good use cases, but I strongly don't think this is one of them)
Hi @ang-zeyu! Thank you for the feedback! I will try out your suggestions in the next commit! |
I managed to overcome this issue by using |
Hi @ang-zeyu! Hmm that is odd. Since I made the change I have not observed this behaviour. May I know which browser you are using so that I may further investigate this issue? Thank you! |
Desktop chrome/firefox + mobile chrome on android, it occurs about 50% of the time. Unlike the gif it also occurs on mcq/radio questions (unrelated to a specific type of question). |
I have tested this on Ubuntu 20.04, on Firefox 109.0.1: Screencast.from.27-02-2023.12.29.07.webmAnd Chromium 110.0.5481.100: Screencast.from.27-02-2023.12.29.41.webmBoth seem to work fine without flickering. |
Chipping in here on a different environment, I'm getting flickering as well on MacOS with Chrome: Screen.Recording.2023-02-27.at.4.20.35.PM.movAnd MacOS with FireFox: Screen.Recording.2023-02-27.at.4.25.14.PM.movBut it's on and off - can't reproduce it consistently. Also nothing appearing on devtools console 🤔 |
@itsyme Try setting throttling using Chrome dev tools (open a mobile view and adjust the throttling option)? I can reproduce the flickering on this branch much more easily when I set throttling to "low-end mobile" Screen.Recording.2023-02-27.at.5.02.57.PM.mov |
I managed to solve the issue by changing my approach. However as a side effect of this, |
@itsyme Sorry for the late response. This UX is completely fine to me, I don't see any flickering anymore as well.
If you'd still like to experiment with the original UX outside of this PR, If I recall previously you were trying to:
I think there's a few other options:
|
// Function to delay test until question is rendered | ||
function timeoutRenderQuestion() { | ||
// eslint-disable-next-line no-promise-executor-return | ||
return new Promise(resolve => setTimeout(resolve, 350)); |
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.
Is there no way to work around using a timeout?
Something like waitForSelector(...).toGoMissing()
(imaginary).
Or creating your own simple transition stub.
There are 17 calls here so resolving this should help improve the speed of tests a fair bit. Unless the runner is parallel, I can't remember..
But don't spend too much time on it, 6s to me is still an ok degradation for now. (just create a follow up issue if we can't resolve this).
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.
@jovyntls could you help to merge in this MR if it looks good to you? 🙇
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.
LGTM! Nice fix @itsyme, let me know if you'll be adding the tests now or opening a future issue for it - will merge if it's the latter
What is the purpose of this pull request?
Overview of changes:
Resolves #2126. Forces intro/outro cards and questions in Quiz to wait for the previous card to leave before allowing the next card to enter.
Anything you'd like to highlight/discuss:
As a side effect of this PR,
gotoNextQuestion
inQuiz.vue
had to be refactored into two functions,gotoNextQuestion
andshowNextQuestion
, in order for the hiding of the current question and the showing of the next question to be called in two separate places. The transition duration was also reduced to keep the same effect as before.Testing instructions:
Proposed commit message: (wrap lines at 72 characters)
Fix expanding of Quiz during transition
Cards in Quiz expands during transition from one to the next due to
both cards being rendered in the Quiz.
This could be undesirable as it is an unexpected behaviour for users
and could lead to confusion when doing the Quiz.
Let's make the next card in the Quiz wait for the previous card to
leave before entering.
This will prevent the expansion of the Quiz component as it is
guaranteed that the Quiz will only have one card rendered at any
one time.
Checklist: ☑️