Skip to content

List.AccordionGroup ignores a controlled expandedId of 0 #5144

Description

@RaphaelFakhri

Current behaviour

When List.AccordionGroup is controlled and expandedId is the number 0, no accordion expands. The accordion with id={0} stays collapsed, even though id={0} is supported since #3936.

ListAccordionGroup resolves the expanded ID with expandedIdProp || expandedId. Because 0 is falsy, the group falls back to its internal state, which is never updated in controlled mode.

Expected behaviour

The accordion whose id matches the controlled expandedId expands, including when the ID is 0.

How to reproduce?

const [expandedId, setExpandedId] = React.useState<number | string>(0);

<List.AccordionGroup expandedId={expandedId} onAccordionPress={setExpandedId}>
  {['First', 'Second'].map((title, index) => (
    <List.Accordion key={title} title={title} id={index}>
      <List.Item title={`${title} item`} />
    </List.Accordion>
  ))}
</List.AccordionGroup>

The first accordion (id={0}) is collapsed on mount, and pressing it never expands it. Pressing the second accordion works.

What have you tried so far?

Replacing expandedIdProp || expandedId with expandedIdProp ?? expandedId in src/components/List/ListAccordionGroup.tsx fixes it.

Your Environment

software version
react-native-paper main (eb4fcbe)

Activity

  1. dave-otf commented on Oct 26, 2026

    @dave-otf

    Numeric 0 is a valid ID here, but the current truthy fallback drops it. I checked current main and confirmed ListAccordionGroup.tsx still uses expandedIdProp || expandedId.

    A regression test could mount the group controlled with expandedId={0} and assert the first row is expanded before any press; then drive the parent to 1 through onAccordionPress and assert the second row opens. That covers both the numeric-zero fallback and the controlled callback round-trip.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions