Skip to content

ECHOES-1422 Allow custom component on FilterDropdown categories items#727

Open
gregaubert wants to merge 1 commit into
mainfrom
greg/filterdropdown-improvements
Open

ECHOES-1422 Allow custom component on FilterDropdown categories items#727
gregaubert wants to merge 1 commit into
mainfrom
greg/filterdropdown-improvements

Conversation

@gregaubert

@gregaubert gregaubert commented Jul 3, 2026

Copy link
Copy Markdown
Member

Part of


Summary by Gitar

  • New category type:
    • Added FilterDropdownCategoryWithContent to support rendering arbitrary custom components in the right panel.
  • Improved component logic:
    • Updated FilterDropdown and FilterDropdownRightPanel to handle keyboard navigation (ArrowLeft) within custom content.
    • Added selectionCount support for custom categories, as item counts cannot be auto-derived.
  • Testing and documentation:
    • Added unit tests for custom content rendering and focus management.
    • Included a Date Range example in FilterDropdown-stories to demonstrate the new functionality.

This will update automatically on new commits.

@netlify

netlify Bot commented Jul 3, 2026

Copy link
Copy Markdown

Deploy Preview for echoes-react ready!

Name Link
🔨 Latest commit d8c08ce
🔍 Latest deploy log https://app.netlify.com/projects/echoes-react/deploys/6a4cacdff07e900008504496
😎 Deploy Preview https://deploy-preview-727--echoes-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Allow custom component on FilterDropdown categories items ECHOES-1422 Allow custom component on FilterDropdown categories items Jul 3, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Jul 3, 2026

Copy link
Copy Markdown

ECHOES-1422

Comment thread src/components/filters/FilterDropdownRightPanel.tsx Outdated
Comment thread src/components/filters/FilterDropdownRightPanel.tsx Outdated
Comment thread src/components/filters/FilterDropdownRightPanel.tsx Outdated
@gregaubert

Copy link
Copy Markdown
Member Author

gitar auto-apply:on

@gregaubert

Copy link
Copy Markdown
Member Author

gitar auto-apply:off

@gregaubert gregaubert force-pushed the greg/filterdropdown-improvements branch 2 times, most recently from 71a131c to aa44f10 Compare July 6, 2026 15:27
Comment thread src/components/filters/FilterDropdownRightPanel.tsx
@gregaubert gregaubert force-pushed the greg/filterdropdown-improvements branch from aa44f10 to d8c08ce Compare July 7, 2026 07:38
@gregaubert gregaubert marked this pull request as ready for review July 7, 2026 07:38
@gitar-bot

gitar-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 resolved / 2 findings

Extends FilterDropdown with custom component support for categories, enabling richer UI like date ranges. Addresses keyboard navigation hijacking and missing focus fallbacks identified during review.

✅ 2 resolved
Edge Case: ArrowLeft in custom content hijacks native input navigation

📄 src/components/filters/FilterDropdownRightPanel.tsx:112-126
In FilterDropdownRightPanel, handleCustomContentKeyDown intercepts every ArrowLeft keypress that bubbles up from anywhere inside the custom content and unconditionally calls e.preventDefault() + onCategoryFocusBack(). This conflicts with native keyboard behavior of focusable descendants. For example, the story's DateRangeContent renders <input type="date"> (and text inputs / textareas are equally common in custom content): the ArrowUp/ArrowDown/ArrowRight keys still adjust the date segment natively, but ArrowLeft is swallowed and jumps focus back to the left panel instead of moving within the input. This produces inconsistent, surprising behavior and effectively makes text/date fields inside custom content partially unusable via the keyboard.

Consider only treating ArrowLeft as "navigate back to category" when the event target is the wrapper itself (or otherwise not an editable/native control), e.g. by checking e.target === customContentRef.current, or by excluding inputs/textareas/selects and contenteditable elements. That keeps left↔right panel navigation working while letting focusable descendants handle their own arrow keys.

Bug: onFocusContent fallback documented but not implemented

📄 src/components/filters/FilterDropdownRightPanel.tsx:85-93 📄 src/components/filters/FilterDropdownTypes.ts:134-141
The JSDoc for onFocusContent states: "When omitted, the first focusable element in the panel is focused automatically." However, the implementation does not do this. In focusFirstItem, the custom-content branch is:

if (hasCustomContent) {
  activeCategory?.onFocusContent?.();
} else {
  listRef.current?.focusFirstItem();
}

When onFocusContent is undefined, the optional call is a no-op and nothing receives focus. A keyboard user who presses ArrowRight/Enter on a custom-content category gets no focus movement into the panel — focus silently stays on the left-panel category. This is both an accessibility regression and a documentation contract violation (any consumer relying on the documented automatic fallback will find it broken).

Either implement the documented fallback (focus the first focusable descendant of the content wrapper) or update the JSDoc to state that focus does not move when onFocusContent is omitted.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next

sonarqube-next Bot commented Jul 7, 2026

Copy link
Copy Markdown

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.

1 participant