Skip to content

ref: Create ListItemSelectedState to declaratively render#116995

Merged
ryan953 merged 3 commits into
masterfrom
ryan953/ref-ListItemSelectedState
Jun 5, 2026
Merged

ref: Create ListItemSelectedState to declaratively render#116995
ryan953 merged 3 commits into
masterfrom
ryan953/ref-ListItemSelectedState

Conversation

@ryan953

@ryan953 ryan953 commented Jun 5, 2026

Copy link
Copy Markdown
Member

Within <ListItemCheckboxProvider> you've usually got to manually create a sub-component so that it's possible to call the hookuseListItemCheckboxContext() properly. That's kind of annoying sometimes, and looks like this:

function MyListWrapper() {
  return (
    <ListItemCheckboxProvider ...>
      <MyListHeader />
    </ListItemCheckboxProvider>
  );
}

function MyListHeader() {
  const {isAnySelected} = useListItemCheckboxContext();
  return isAnySelected ? <BulkActions /> : <NormalTableHeaders />;
}

Ideally we can have all my page-specific stuff in the same file/component, which means the ListItemCheckbox stuff needs a better interface. This is a step in that direction and looks like:

function MyList() {
  return (
    <ListItemCheckboxProvider ...>
      <ListItemSelectedState selected="none">
        <NormalTableHeaders />
      </ListItemSelectedState>
      <ListItemSelectedState selected="any">
        <BulkActions />
      </ListItemSelectedState>
    </ListItemCheckboxProvider>
  );
}

…within ListItemCheckboxProvider/useListItemCheckboxContext without having to intentionally create sub-components
@ryan953 ryan953 requested review from a team as code owners June 5, 2026 17:52
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 5, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1eb50e4. Configure here.

Comment thread static/app/utils/list/listItemSelectedState.tsx Outdated
@ryan953 ryan953 changed the title ref: Create ListItemSelectedState to declaratively render components … ref: Create ListItemSelectedState to declaratively render Jun 5, 2026
Comment thread static/app/utils/list/listItemSelectedState.tsx
ryan953 and others added 2 commits June 5, 2026 11:05
Test each valid selected value (none, all, indeterminate, indeterminate-or-all) and verify that mismatched states result in nothing rendered.

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
@ryan953 ryan953 merged commit 9e49791 into master Jun 5, 2026
70 checks passed
@ryan953 ryan953 deleted the ryan953/ref-ListItemSelectedState branch June 5, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants