Faq page fix#84
Conversation
🚀 PR Received SuccessfullyHello @dikshajha13, Thank you for taking the initiative to contribute to this project. Please ensure that your PR follows all project guidelines properly before requesting review.
|
📝 WalkthroughWalkthroughA new FAQ page component is added with category-based filtering and accordion-style expandable items, keyboard accessibility support, and integration into the application routing at ChangesFAQ Page Feature
Sequence DiagramsequenceDiagram
participant User
participant CategoryButton
participant FAQItem
User->>CategoryButton: Click category button
CategoryButton->>CategoryButton: Update selectedCategory
CategoryButton->>FAQItem: Filter and render items
User->>FAQItem: Click or press Enter/Space
FAQItem->>FAQItem: Toggle expanded state
FAQItem->>FAQItem: Conditionally render answer
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/src/pages/FAQpage.jsx (1)
157-181: ⚡ Quick winExpose expanded/collapsed state for screen readers.
The accordion trigger currently lacks
aria-expandedandaria-controls, so assistive tech users don’t get clear state/context feedback.Suggested fix
<div role="button" tabIndex={0} + aria-expanded={openQuestion === index} + aria-controls={`${item.category}-${index}-content`} onKeyDown={(e)=>{ if(e.key === "Enter" || e.key === " "){ setOpenQuestion(openQuestion===index?null:index); } }} > @@ - {openQuestion ===index &&( - <p className="mt-3 text-gray-600 dark:text-gray-300"> + {openQuestion ===index &&( + <p id={`${item.category}-${index}-content`} className="mt-3 text-gray-600 dark:text-gray-300"> {item.answer} </p>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/pages/FAQpage.jsx` around lines 157 - 181, The clickable FAQ accordion div (role="button" with onKeyDown) does not expose its expanded state or link to the content for screen readers; update the trigger to include an aria-expanded attribute set to a boolean expression (e.g. aria-expanded={openQuestion===index}) and add aria-controls referencing a unique id for the answer pane (generate id using index or item id), and ensure the answer paragraph rendered by the condition has that id (e.g. id={`faq-answer-${index}`}) so assistive tech can associate the control with its region; keep existing behavior using setOpenQuestion and openQuestion for state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/pages/FAQpage.jsx`:
- Around line 157-165: The onKeyDown handler for the accordion toggling (the
inline function that checks e.key === "Enter" || e.key === " ") should call
e.preventDefault() when the Space key is pressed (and optionally for Enter)
before calling setOpenQuestion(openQuestion===index?null:index) to stop the
browser from scrolling; update the handler attached to the div (the
role="button" block) to prevent default on space and then perform the toggle
using the existing setOpenQuestion/openQuestion/index logic.
---
Nitpick comments:
In `@frontend/src/pages/FAQpage.jsx`:
- Around line 157-181: The clickable FAQ accordion div (role="button" with
onKeyDown) does not expose its expanded state or link to the content for screen
readers; update the trigger to include an aria-expanded attribute set to a
boolean expression (e.g. aria-expanded={openQuestion===index}) and add
aria-controls referencing a unique id for the answer pane (generate id using
index or item id), and ensure the answer paragraph rendered by the condition has
that id (e.g. id={`faq-answer-${index}`}) so assistive tech can associate the
control with its region; keep existing behavior using setOpenQuestion and
openQuestion for state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7198547e-4c9f-4ce3-8422-db97b80741d7
⛔ Files ignored due to path filters (2)
frontend/package-lock.jsonis excluded by!**/package-lock.jsonpackage-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
frontend/src/App.jsxfrontend/src/pages/FAQpage.jsx
| <div | ||
| role="button" | ||
| tabIndex={0} | ||
| onKeyDown={(e)=>{ | ||
| if(e.key === "Enter" || e.key === " "){ | ||
| setOpenQuestion(openQuestion===index?null:index); | ||
| } | ||
| }} | ||
| > |
There was a problem hiding this comment.
Prevent page scroll when toggling with Space key.
On Line 161, space key toggles the accordion but does not prevent default scrolling behavior, which can cause a jarring keyboard UX.
Suggested fix
<div
role="button"
tabIndex={0}
onKeyDown={(e)=>{
if(e.key === "Enter" || e.key === " "){
+ e.preventDefault();
setOpenQuestion(openQuestion===index?null:index);
}
}}
>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <div | |
| role="button" | |
| tabIndex={0} | |
| onKeyDown={(e)=>{ | |
| if(e.key === "Enter" || e.key === " "){ | |
| setOpenQuestion(openQuestion===index?null:index); | |
| } | |
| }} | |
| > | |
| <div | |
| role="button" | |
| tabIndex={0} | |
| onKeyDown={(e)=>{ | |
| if(e.key === "Enter" || e.key === " "){ | |
| e.preventDefault(); | |
| setOpenQuestion(openQuestion===index?null:index); | |
| } | |
| }} | |
| > |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@frontend/src/pages/FAQpage.jsx` around lines 157 - 165, The onKeyDown handler
for the accordion toggling (the inline function that checks e.key === "Enter" ||
e.key === " ") should call e.preventDefault() when the Space key is pressed (and
optionally for Enter) before calling
setOpenQuestion(openQuestion===index?null:index) to stop the browser from
scrolling; update the handler attached to the div (the role="button" block) to
prevent default on space and then perform the toggle using the existing
setOpenQuestion/openQuestion/index logic.
Description
This PR adds a new FAQ section to the CodeLens Explore page and improves the existing FAQ component in App.jsx integration. The FAQ is organized into categories (General, Tools, Contests, Dashboard) and provides an interactive accordion-style UI for better user understanding of the platform.
It also includes improvements to routing and minor UI updates for better structure and maintainability.
Changes made
Added categorized FAQ data with interactive accordion UI
Integrated FAQ section into Explore flow
Improved FAQ category switching and state handling
Updated routing to include /faq page
Minor fixes and cleanup in App.jsx
UI design Screenshots
Summary by CodeRabbit
/faqwith categorized questions