Skip to content

Fix off-by-one in pgResponsive when any <th> is hidden#2106

Merged
luanfreitasdev merged 1 commit into
Power-Components:6.xfrom
lsmedia:fix/1940-pgresponsive-nth-child-off-by-one
May 11, 2026
Merged

Fix off-by-one in pgResponsive when any <th> is hidden#2106
luanfreitasdev merged 1 commit into
Power-Components:6.xfrom
lsmedia:fix/1940-pgresponsive-nth-child-off-by-one

Conversation

@lsmedia

@lsmedia lsmedia commented May 8, 2026

Copy link
Copy Markdown
Contributor

⚡ PowerGrid - Pull Request

  • Bug fix
  • Enhancement
  • New feature
  • Breaking change

Description

PR #1940 introduced a regression that crashes pgResponsive with null.textContent.
getItemsToHide() pushes visibleThs.indexOf(item) + 1, but the value is later used as a CSS :nth-child(n) selector — and :nth-child counts all siblings, including display: none ones. As soon as any <th> is hidden (which is always true on initial render due to the x-show="hasHiddenElements" toggle column in tr.blade.php), the indexes drift and :nth-child resolves to the wrong column.

Fix: index against the unfiltered items list, plus a defensive ?.textContent ?? '' guard

The filtering from #1940 stays in place for the sort/iterate step, so hidden columns still don’t leak into the expand area — only the index used for :nth-child is corrected.

Related Issue(s):


Documentation

This PR requires Documentation update?

  • Yes
  • No
  • I have already submitted a Documentation pull request.

@lsmedia lsmedia mentioned this pull request May 8, 2026
7 tasks
@luanfreitasdev luanfreitasdev merged commit 6b28035 into Power-Components:6.x May 11, 2026
27 checks passed
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.

2 participants