feat: FacetWP collapse & expand html#56
Conversation
There was a problem hiding this comment.
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_scriptsto populateFWP()->display->json['expand']andFWP()->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.
| 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>'; |
There was a problem hiding this comment.
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.
| 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>'; |
| 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>'; |
There was a problem hiding this comment.
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.
| 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>'; |
mvdhoek1
left a comment
There was a problem hiding this comment.
CoPilot heeft nog wat handige comments, ziet er nice uit verder!
|
type=button hoeft niet, die aria-hidden="true" is wel netjes (ook al doet FontAwesome dat voor ons) |
No description provided.