Skip to content

feat(gallery): add new required gallery-item component for child items#31195

Draft
brandyscarney wants to merge 14 commits into
nextfrom
FW-7301
Draft

feat(gallery): add new required gallery-item component for child items#31195
brandyscarney wants to merge 14 commits into
nextfrom
FW-7301

Conversation

@brandyscarney
Copy link
Copy Markdown
Member

@brandyscarney brandyscarney commented Jun 5, 2026

Issue number: internal


What is the current behavior?

The Gallery component queries all direct children and uses them to build both the uniform and masonry layouts. This causes issues when a wrapper element exists between the gallery and the gallery items. For example:

<ion-gallery>
  <div class="some-wrapper">
    <img src="/src/components/gallery/test/assets/01.png" alt="One" />
    <img src="/src/components/gallery/test/assets/02.png" alt="Two" />
    <img src="/src/components/gallery/test/assets/03.png" alt="Three" />
    <img src="/src/components/gallery/test/assets/04.png" alt="Four" />
  </div>
</ion-gallery>

In this scenario, the gallery treats the wrapper as a single item and does not correctly lay out the images contained within it.

What is the new behavior?

Several approaches were considered:

  1. Add a class or attribute to wrapper elements that the Gallery could use to locate its items.
  2. Query for items using a specific class or attribute when present, and fall back to querying direct children otherwise.
  3. Introduce a new ion-gallery-item component that encapsulates all item-related styling and can contain arbitrary content (img, div, etc.).

We ultimately chose option 3 and introduced a new ion-gallery-item component. The ion-gallery component now queries for ion-gallery-item elements instead of relying on direct children.

As such, this PR does the following:

  • Adds a new ion-gallery-item component.
  • Updates ion-gallery to query for ion-gallery-item elements.
  • Updates existing E2E and spec tests to use the new structure.
  • Adds new E2E and spec tests for ion-gallery-item.
  • Adds an E2E test verifying that wrapper elements around gallery items are effectively transparent to gallery layout calculations.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev build: 8.8.9-dev.11780690416.19d0d667

Previews:

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment Jun 5, 2026 8:14pm

Request Review

@github-actions github-actions Bot added package: core @ionic/core package package: angular @ionic/angular package package: vue @ionic/vue package package: react @ionic/react package labels Jun 5, 2026
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This change is actually more accurate. In both images the blue rectangle I added is 16px tall. You can see on the left there is a half pixel above and below it.

Image

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

Labels

package: angular @ionic/angular package package: core @ionic/core package package: react @ionic/react package package: vue @ionic/vue package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant