Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 2, 2026

SelectPanel experiences input lag when filtering large lists because expensive list rendering blocks keystrokes. This implements React's useDeferredValue pattern already used in Autocomplete.

Implementation

Added useDeferredValue to FilteredActionList to separate immediate UI updates from expensive rendering:

// Immediate: text input remains responsive
const [filterValue, setInternalFilterValue] = useProvidedStateOrCreate(...)

// Deferred: expensive list rendering doesn't block typing
const deferredItems = useDeferredValue(items)

Updated to use deferredItems:

  • List rendering (grouped and ungrouped)
  • getItemListForEachGroup callback
  • useAnnouncements hook
  • onInputKeyDown keyboard handler

Kept immediate items:

  • Select-all checkbox (requires immediate state)

Changelog

Changed

  • FilteredActionList now uses useDeferredValue for list rendering operations to prevent input lag with large lists

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

All existing SelectPanel and ActionList tests pass. The change is internal to FilteredActionList with no API changes.

A changeset has been added to document this performance improvement for the changelog.

Merge checklist

Original prompt

Problem

The SelectPanel component can experience input lag when filtering large lists because the filtering operation runs synchronously on every keystroke, blocking user input.

The Autocomplete component already addresses this problem by using React's useDeferredValue hook (see packages/react/src/Autocomplete/Autocomplete.tsx), which allows typing to remain responsive while filtering large lists at lower priority.

Solution

Apply the same pattern from Autocomplete to SelectPanel and FilteredActionList:

  1. In FilteredActionList.tsx: Use useDeferredValue to defer the filter value used for rendering the filtered items list, while keeping the input value immediate for display in the text input.

  2. The approach should:

    • Keep the text input immediately responsive (show what the user types without delay)
    • Defer the expensive filtering/rendering of the list items
    • Follow the same pattern already established in Autocomplete

Implementation Reference

The Autocomplete component shows how this should work:

// From packages/react/src/Autocomplete/Autocomplete.tsx
const deferredInputValue = useDeferredValue(inputValue)

And the context is split to provide:

  • Immediate input value for the text input display
  • Deferred input value for the menu filtering

Acceptance Criteria

  • FilteredActionList uses useDeferredValue for the filter value passed to item rendering
  • The text input remains immediately responsive during typing
  • The list filtering is deferred to avoid blocking keystrokes
  • Existing tests continue to pass
  • The pattern is consistent with how Autocomplete handles this

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot
Copy link

changeset-bot bot commented Jan 2, 2026

🦋 Changeset detected

Latest commit: 773fe7d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI and others added 2 commits January 2, 2026 21:33
…ith large lists

- Import useDeferredValue from React
- Create deferredItems using useDeferredValue(items)
- Use immediate filterValue for TextInput display (keeps typing responsive)
- Use deferredItems for expensive list rendering operations
- Update getItemListForEachGroup to use deferredItems
- Use deferredItems in ActionList rendering (both grouped and ungrouped)
- Use deferredItems for useAnnouncements to defer announcements
- Keep immediate items for selectAll logic and keyboard interactions

This implementation follows the same pattern as Autocomplete.tsx, where:
- Immediate values are used for user-facing UI (TextInput)
- Deferred values are used for expensive operations (list rendering)
- React can defer the expensive work while keeping input responsive

Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
- Update onInputKeyDown to use deferredItems instead of items
- This ensures keyboard navigation (Enter key) operates on the same
  deferred items that are rendered, preventing potential mismatches
- Addresses code review feedback about consistency between keyboard
  handlers and rendered items

Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize SelectPanel component with deferred value filtering Optimize SelectPanel filtering performance with useDeferredValue Jan 2, 2026
Copilot AI requested a review from mattcosta7 January 2, 2026 21:44
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jan 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@mattcosta7
Copy link
Contributor

@copilot add a changeset

Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 2, 2026

@copilot add a changeset

Added changeset in commit 773fe7d. The changeset documents this as a patch release with a performance improvement to FilteredActionList.

@mattcosta7
Copy link
Contributor

Closing via #7411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants