freeCodeCamp / ui

freeCodeCamp's UI Component Library
BSD 3-Clause "New" or "Revised" License
14 stars 16 forks source link

[Quiz] Correct count is not displayed properly on Storybook demo #366

Open huyenltnguyen opened 4 days ago

huyenltnguyen commented 4 days ago

Description

This isn't a bug in the component, but in this Storybook demo: https://opensource.freecodecamp.org/ui/?path=/story/components-quiz--with-validation.

In the demo, we only want to display the correct answer count on submit, but the number shows up on the screen on load:

Screenshot ![Image](https://github.com/user-attachments/assets/2734915d-ccb1-4b60-a593-f93e3b5066e4)

Code:

https://github.com/freeCodeCamp/ui/blob/f23cd2833eecd2248b84f6d3be93267f27c62989/src/quiz/quiz.stories.tsx#L106

While we're at it, we should improve the accessibility of the correct count message as well. In order for screen readers to pick up the message, it should be placed inside a live region:

<div aria-live="polite">
  <p>Correct answers: {correctAnswerCount}</p>
</div>

Changes needed

Update the rendering logic to:

a2937 commented 4 hours ago

I am getting these weird errors and can't contribute.

Image

Edit: This happens on WSL 2. Looks like Windows standalone may be fine.