Skip to content

fix(ios): respect atIndex in getAttributes#4912

Open
vazidmansuri005 wants to merge 1 commit intowix:masterfrom
vazidmansuri005:fix/atIndex-getAttributes-ios
Open

fix(ios): respect atIndex in getAttributes#4912
vazidmansuri005 wants to merge 1 commit intowix:masterfrom
vazidmansuri005:fix/atIndex-getAttributes-ios

Conversation

@vazidmansuri005
Copy link

@vazidmansuri005 vazidmansuri005 commented Feb 22, 2026

Description

Root cause

The attributes computed property in Element.swift never checked self.index. When multiple elements matched the predicate, it unconditionally mapped over all views and returned them in an elements array — regardless of whether atIndex() was specified.

Fix

Added index-aware logic to the attributes property, matching the pattern already used by the view property (which correctly handles self.index).

Scenario Before After
atIndex(N).getAttributes() with multiple matches Returns { elements: [...] } (ignores index) Returns single element attributes at index N
getAttributes() with single match Returns single element attributes No change
getAttributes() without atIndex, multiple matches Returns { elements: [...] } No change

Tests

  • Added e2e tests in 33.attributes.test.js for atIndex + getAttributes on iOS (both legacy and new arch)
  • Tests verify that when atIndex is used, the result is a single element object (no elements array wrapper)

The `attributes` property on `Element` was ignoring `self.index`,
causing `element(...).atIndex(N).getAttributes()` to return all
matching elements instead of the one at the specified index.

This aligns the `attributes` property with the existing `view` property,
which already correctly handles `self.index`.

Fixes wix#4633
@vazidmansuri005 vazidmansuri005 force-pushed the fix/atIndex-getAttributes-ios branch from 9750b05 to 607ec33 Compare February 23, 2026 06:38
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.

atIndex() has no effect over getAttributes()

1 participant