-
Notifications
You must be signed in to change notification settings - Fork 1
Add dropdown sections, headings, and separators #20
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
Conversation
Add three new components to organize dropdown menus: - dropdown_separator: Visual divider with role="separator" - dropdown_section: Groups related items with role="group" - dropdown_heading: Labels sections with role="presentation" The JavaScript hook automatically establishes aria-labelledby relationships between sections and their headings when a heading is the first child of a section. This eliminates manual ID management while maintaining full accessibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Pull Request Review - Dropdown Sections, Headings, and SeparatorsSummaryThis PR adds three new components for organizing dropdown menus: ✅ StrengthsCode Quality
Accessibility
Testing
🔍 Areas for Consideration1. JavaScript Hook - Section Label Setup Logic (Minor)Location: The setupSectionLabels() {
const dropdownId = this.el.id
const sections = this.el.querySelectorAll('[role="group"]')
sections.forEach((section, sectionIndex) => {
const firstChild = section.firstElementChild
// Consider: What if section has no children? Current code handles this via optional chaining
if (firstChild && firstChild.getAttribute('role') === 'presentation') {
if (!firstChild.id) {
firstChild.id = `${dropdownId}-section-${sectionIndex}-heading`
}
section.setAttribute('aria-labelledby', firstChild.id)
}
})
}Verdict: Current implementation is fine. 2. Documentation - Heading ID Attribute (Informational)Location: The Suggestion: The current documentation is actually good - it mentions "Auto-generated by the JS hook if not provided." Consider this resolved. 3. Test Coverage - Edge Cases (Nice to Have)The tests are comprehensive, but here are some additional scenarios to consider for future enhancement (not blockers):
These are all handled correctly by the current implementation, but explicit tests would document the expected behavior. 4. Performance - No ConcernsThe 🐛 Potential IssuesNo Issues FoundI did not identify any bugs, security concerns, or critical problems in this PR. 📊 Test Coverage AssessmentExcellent coverage ✅ Tests verify:
🎯 Alignment with Project GuidelinesFully aligned ✅
🎨 Code Style
🚀 RecommendationAPPROVE ✅ This PR is ready to merge. The implementation is solid, well-tested, and follows all project conventions. The automatic ARIA relationship management is elegant and provides excellent developer experience. Minor Enhancement Opportunities (Optional, Future Work)
Great work on this feature! The automatic aria-labelledby setup is particularly clever and removes potential for developer error. |
The dropdown sections tests were failing because the fixture template was not wired up in the main template file. Additionally, the tests had incorrect selectors for keyboard navigation and separator visibility. Changes: - Add dropdown_sections entry to fixtures_live.html.heex - Remove unused @dropdown_container module attribute - Fix separator test to handle invisible elements with Query.visible(false) - Replace :nth-of-type selectors with specific IDs for keyboard navigation
Code Review: Dropdown Sections, Headings, and SeparatorsGreat work on this PR! The implementation of dropdown sections with automatic ARIA relationships is well-designed and follows accessibility best practices. Here's my detailed review: ✅ StrengthsCode Quality
Accessibility
Testing
🔍 Observations & Minor Suggestions1. JavaScript Hook: Selector Specificity (dropdown.js:350-363)The Suggestion: Scope the query to within the menu: setupSectionLabels() {
const dropdownId = this.el.id
const menu = this.el.querySelector(SELECTORS.MENU)
const sections = menu.querySelectorAll('[role="group"]')
// ... rest of implementation
}This is a minor point since dropdowns are self-contained, but it improves robustness. 2. Test Assertion:
|
Summary
This PR adds three new components to organize dropdown menus with proper ARIA structure:
dropdown_separator- Visual divider between menu groups (role="separator")dropdown_section- Semantic grouping container (role="group")dropdown_heading- Section labels (role="presentation")Key Feature: Automatic ARIA Relationships
The JavaScript hook now automatically establishes
aria-labelledbyrelationships between sections and headings:aria-labelledbyattribute is automatically set to reference the headingExample Usage
Accessibility
Test Coverage
🤖 Generated with Claude Code