Skip to content

Commit 73e59a4

Browse files
committed
feat: add CSS utility for stretching label slot in wa-tree component
1 parent 418ec99 commit 73e59a4

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { css } from 'lit';
2+
3+
/**
4+
* Stretch the Web Awesome label slot across the rest of the tree row.
5+
*
6+
* By default the slot is only as wide as its content, so clicks (and the context menu’s
7+
* synthetic click) in the empty area beside a short name often miss the slotted nodes.
8+
* `wa-tree` only updates selection when mousedown and click targets line up, so those
9+
* misses leave the wrong row selected. `flex: 1` makes the label column fill the row
10+
* so hits stay on the item’s content.
11+
*
12+
* Applied via `LyraWidget.finalizeStyles`: document-level CSS cannot target `::part()`
13+
* on `wa-tree-item` that lives only inside nested Lit shadow roots.
14+
*/
15+
export const waTreeLabelSlotStretch = css`
16+
wa-tree-item::part(label) {
17+
flex: 1;
18+
min-width: 0;
19+
}
20+
`;

packages/core/src/parts/part.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export abstract class LyraPart extends LyraContainer {
282282
}
283283
`;
284284

285-
protected static finalizeStyles(styles?: CSSResultGroup) {
285+
static finalizeStyles(styles?: CSSResultGroup) {
286286
const own = super.finalizeStyles(styles);
287287
return [LyraPart.baseStyles, ...own];
288288
}

packages/core/src/widgets/widget.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {LitElement, PropertyValues} from "lit";
1+
import {LitElement, PropertyValues, type CSSResultGroup} from "lit";
2+
import {waTreeLabelSlotStretch} from "../externals/wa-tree-shadow-parts";
23
import {subscribe as event_subscribe, unsubscribe as event_unsubscribe, type SubscriptionToken} from "../core/events";
34
import {toastError, toastInfo} from "../core/toast";
45
import {commandRegistry, ExecuteParams} from "../core/commandregistry";
@@ -14,6 +15,10 @@ Object.defineProperty(LitElement.prototype, "model", {
1415
const LyraWidgetBase = SignalWatcher(LitElement) as unknown as typeof LitElement;
1516

1617
export abstract class LyraWidget extends LyraWidgetBase {
18+
static finalizeStyles(styles?: CSSResultGroup) {
19+
return [waTreeLabelSlotStretch, ...super.finalizeStyles(styles)];
20+
}
21+
1722
private signalCleanups = new Set<() => void>();
1823
private eventSubscriptions = new Set<SubscriptionToken>();
1924

0 commit comments

Comments
 (0)