Skip to content

Commit 98002b3

Browse files
committed
fix(label-group): address review feedback on pf-label-group
- Remove add-label-mode concept; adding labels is external code's job - Remove add-label demos (auto, from-list, custom-form) - Align component with pf-chip-group patterns: - Use `@queryAssignedNodes` instead of manual slot querying - Use `?hidden` binding instead of conditional rendering (SSR-friendly) - Compute overflow text inline in template via `#remaining` getter - Handle removal via event listener pattern (cancelable) - Export proper Event subclasses - Fix CSS: - Replace hardcoded colors with PF global token fallbacks - Use CSS logical properties throughout - Add `::slotted([hidden])` rule (pf-label lacks `:host([hidden])`) - Remove `.add-label` styles - Add CSS custom property declarations on `:host` - Remove superfluous `type: String` from `@property` decorators - Add `@summary` JSDoc tag - Rewrite tests following pf-chip-group patterns: - Use `a11ySnapshot` assertions - Use `function()` instead of arrow functions - Add tests for overflow, closeable, num-labels, category, a11y - Clean up demos with minimal imports - Update changeset and README to match project conventions Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c90b4ff commit 98002b3

13 files changed

Lines changed: 347 additions & 742 deletions

.changeset/yummy-eagles-itch.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
"@patternfly/elements": minor
33
---
44

5-
Added `<pf-label-group>`.
5+
Added `<pf-label-group>`.
66

7-
8-
A label group displays multiple labels together, helping users visualize related categories, filters, or items.
9-
Each label can be removed individually, and the entire group can also be cleared at once.
10-
The element automatically handles overflow for long lists of labels and supports both horizontal and vertical layouts.
11-
12-
Use this when you need to show multiple tags, filters, or categorized items that users can remove, add, or adjust dynamically.
13-
Avoid using it for single, standalone labels — consider using `<pf-label>` instead.
7+
A **label group** is a collection of labels that can be grouped by category
8+
and used to represent one or more values assigned to a single attribute.
9+
When the number of labels exceeds the configured limit, additional labels
10+
are hidden under an overflow indicator.
1411

1512
```html
16-
<pf-label-group label="Filters" add-label-mode="fromList">
13+
<pf-label-group>
14+
<span slot="category">Filters</span>
1715
<pf-label removable>Security</pf-label>
1816
<pf-label removable>Performance</pf-label>
1917
<pf-label removable>Networking</pf-label>

elements/pf-label-group/README.md

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Label Group
2-
A label group is a collection of labels that can be grouped by category and used to represent one or more values assigned to a single attribute.
3-
When the number of labels exceeds `numLabels`, additional labels are hidden under an overflow label.
2+
A label group is a collection of labels that can be grouped by category and
3+
used to represent one or more values assigned to a single attribute. When
4+
the number of labels exceeds the configured limit, additional labels are
5+
hidden under an overflow indicator.
6+
7+
Read more about Label Group in the [PatternFly Elements Label Group documentation](https://patternflyelements.org/components/label-group)
48

59
## Installation
610

@@ -22,41 +26,21 @@ Then once installed, import it to your application:
2226
import '@patternfly/elements/pf-label-group/pf-label-group.js';
2327
```
2428

25-
---
26-
2729
## Usage
2830

2931
```html
30-
<pf-label-group num-labels="2">
31-
<span slot="category">Fruit Types</span>
32-
<pf-label>Apple</pf-label>
33-
<pf-label>Banana</pf-label>
34-
<pf-label>Orange</pf-label>
32+
<pf-label-group>
33+
<pf-label color="blue">Security</pf-label>
34+
<pf-label color="green">Performance</pf-label>
35+
<pf-label color="red">Networking</pf-label>
3536
</pf-label-group>
3637
```
3738

38-
Displays a group of labels, showing only the first two and an overflow label like “1 more” that expands on click.
39-
40-
## Adding Labels
41-
42-
`<pf-label-group>` supports adding new labels dynamically through the `addLabelMode` attribute:
43-
44-
- `none` (default): No label addition.
45-
- `autoNoEdit`: Adds labels automatically without user editing.
46-
- `fromList`: Allows adding labels from a predefined list.
47-
- `customForm`: Lets users add custom labels via a form.
48-
49-
Example:
50-
39+
With a category:
5140
```html
52-
<pf-label-group add-label-mode="fromList">
41+
<pf-label-group>
5342
<span slot="category">Filters</span>
5443
<pf-label removable>Security</pf-label>
5544
<pf-label removable>Performance</pf-label>
5645
</pf-label-group>
57-
58-
Use this feature when you want users to dynamically add new tags or filters to the group.
59-
60-
---
61-
62-
46+
```
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
<pf-label-group open>
2-
<pf-label color="blue">Blue Label</pf-label>
3-
<pf-label color="green">Green Label</pf-label>
4-
<pf-label color="orange">Orange Label</pf-label>
1+
<pf-label-group>
2+
<pf-label color="blue">Blue</pf-label>
3+
<pf-label color="green">Green</pf-label>
4+
<pf-label color="orange">Orange</pf-label>
55
</pf-label-group>
66

77
<script type="module">
88
import '@patternfly/elements/pf-label-group/pf-label-group.js';
9-
import '@patternfly/elements/pf-label/pf-label.js';
10-
import '@patternfly/elements/pf-button/pf-button.js';
11-
</script>
9+
</script>

elements/pf-label-group/demo/label-group-add-label-auto.html

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)