Skip to content

feat: FacetWP collapse & expand html#56

Merged
ictbeheer merged 2 commits into
mainfrom
feat/facetwp-collapse
Mar 30, 2026
Merged

feat: FacetWP collapse & expand html#56
ictbeheer merged 2 commits into
mainfrom
feat/facetwp-collapse

Conversation

@ictbeheer
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds custom expand/collapse button HTML into FacetWP’s front-end JSON payload so the UI can render branded/a11y-friendly toggle controls.

Changes:

  • Hook into facetwp_scripts to populate FWP()->display->json['expand'] and FWP()->display->json['collapse'].
  • Provide custom button markup (icons + screen-reader text) for expand/collapse behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/FacetWP.php Outdated
Comment on lines +155 to +156
FWP()->display->json['expand'] = '<button class="facetwp-button-collapse-expand" aria-expanded="false"><i class="fa-regular fa-plus"></i><span class="sr-only">Klap uit</span></button>';
FWP()->display->json['collapse'] = '<button class="facetwp-button-collapse-collapse" aria-expanded="true"><i class="fa-regular fa-minus"></i><span class="sr-only">Klap in</span></button>';
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The generated elements don’t specify type="button". If FacetWP renders this inside a , the default type="submit" can cause unintended form submission when toggling expand/collapse. Add an explicit type="button" to both buttons.

Suggested change
FWP()->display->json['expand'] = '<button class="facetwp-button-collapse-expand" aria-expanded="false"><i class="fa-regular fa-plus"></i><span class="sr-only">Klap uit</span></button>';
FWP()->display->json['collapse'] = '<button class="facetwp-button-collapse-collapse" aria-expanded="true"><i class="fa-regular fa-minus"></i><span class="sr-only">Klap in</span></button>';
FWP()->display->json['expand'] = '<button type="button" class="facetwp-button-collapse-expand" aria-expanded="false"><i class="fa-regular fa-plus"></i><span class="sr-only">Klap uit</span></button>';
FWP()->display->json['collapse'] = '<button type="button" class="facetwp-button-collapse-collapse" aria-expanded="true"><i class="fa-regular fa-minus"></i><span class="sr-only">Klap in</span></button>';

Copilot uses AI. Check for mistakes.
Comment thread src/FacetWP.php Outdated
Comment on lines +155 to +156
FWP()->display->json['expand'] = '<button class="facetwp-button-collapse-expand" aria-expanded="false"><i class="fa-regular fa-plus"></i><span class="sr-only">Klap uit</span></button>';
FWP()->display->json['collapse'] = '<button class="facetwp-button-collapse-collapse" aria-expanded="true"><i class="fa-regular fa-minus"></i><span class="sr-only">Klap in</span></button>';
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The decorative Font Awesome <i> icons should be hidden from assistive tech (e.g., aria-hidden="true") since the accessible label is provided via the .sr-only text. Otherwise screen readers may announce the icon element redundantly.

Suggested change
FWP()->display->json['expand'] = '<button class="facetwp-button-collapse-expand" aria-expanded="false"><i class="fa-regular fa-plus"></i><span class="sr-only">Klap uit</span></button>';
FWP()->display->json['collapse'] = '<button class="facetwp-button-collapse-collapse" aria-expanded="true"><i class="fa-regular fa-minus"></i><span class="sr-only">Klap in</span></button>';
FWP()->display->json['expand'] = '<button class="facetwp-button-collapse-expand" aria-expanded="false"><i class="fa-regular fa-plus" aria-hidden="true"></i><span class="sr-only">Klap uit</span></button>';
FWP()->display->json['collapse'] = '<button class="facetwp-button-collapse-collapse" aria-expanded="true"><i class="fa-regular fa-minus" aria-hidden="true"></i><span class="sr-only">Klap in</span></button>';

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@mvdhoek1 mvdhoek1 left a comment

Choose a reason for hiding this comment

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

CoPilot heeft nog wat handige comments, ziet er nice uit verder!

@YvetteNikolov
Copy link
Copy Markdown
Contributor

type=button hoeft niet, die aria-hidden="true" is wel netjes (ook al doet FontAwesome dat voor ons)

@ictbeheer ictbeheer merged commit e585ab4 into main Mar 30, 2026
@ictbeheer ictbeheer deleted the feat/facetwp-collapse branch March 30, 2026 13:05
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.

4 participants