@@ -6,15 +6,10 @@ import {
6
6
h ,
7
7
Host ,
8
8
Prop ,
9
+ State ,
9
10
VNode ,
10
11
Watch ,
11
12
} from "@stencil/core" ;
12
- import {
13
- ConditionalSlotComponent ,
14
- connectConditionalSlotComponent ,
15
- disconnectConditionalSlotComponent ,
16
- } from "../../utils/conditionalSlot" ;
17
- import { getSlotted } from "../../utils/dom" ;
18
13
import { guid } from "../../utils/guid" ;
19
14
import {
20
15
InteractiveComponent ,
@@ -26,6 +21,7 @@ import { getAncestors, getDepth, isSingleLike } from "../combobox/utils";
26
21
import { Scale , SelectionMode } from "../interfaces" ;
27
22
import { getIconScale } from "../../utils/component" ;
28
23
import { IconNameOrString } from "../icon/interfaces" ;
24
+ import { slotChangeHasContent } from "../../utils/dom" ;
29
25
import { CSS , SLOTS } from "./resources" ;
30
26
31
27
/**
@@ -37,7 +33,7 @@ import { CSS, SLOTS } from "./resources";
37
33
styleUrl : "combobox-item.scss" ,
38
34
shadow : true ,
39
35
} )
40
- export class ComboboxItem implements ConditionalSlotComponent , InteractiveComponent {
36
+ export class ComboboxItem implements InteractiveComponent {
41
37
// --------------------------------------------------------------------------
42
38
//
43
39
// Properties
@@ -158,6 +154,8 @@ export class ComboboxItem implements ConditionalSlotComponent, InteractiveCompon
158
154
159
155
@Element ( ) el : HTMLCalciteComboboxItemElement ;
160
156
157
+ @State ( ) hasContent = false ;
158
+
161
159
// --------------------------------------------------------------------------
162
160
//
163
161
// Lifecycle
@@ -166,11 +164,6 @@ export class ComboboxItem implements ConditionalSlotComponent, InteractiveCompon
166
164
167
165
connectedCallback ( ) : void {
168
166
this . ancestors = getAncestors ( this . el ) ;
169
- connectConditionalSlotComponent ( this ) ;
170
- }
171
-
172
- disconnectedCallback ( ) : void {
173
- disconnectConditionalSlotComponent ( this ) ;
174
167
}
175
168
176
169
componentDidRender ( ) : void {
@@ -202,6 +195,10 @@ export class ComboboxItem implements ConditionalSlotComponent, InteractiveCompon
202
195
//
203
196
// --------------------------------------------------------------------------
204
197
198
+ private handleDefaultSlotChange = ( event : Event ) : void => {
199
+ this . hasContent = slotChangeHasContent ( event ) ;
200
+ } ;
201
+
205
202
toggleSelected ( ) : Promise < void > {
206
203
const isSinglePersistSelect = this . selectionMode === "single-persist" ;
207
204
@@ -262,15 +259,11 @@ export class ComboboxItem implements ConditionalSlotComponent, InteractiveCompon
262
259
}
263
260
264
261
renderChildren ( ) : VNode {
265
- if ( getSlotted ( this . el ) ) {
266
- return (
267
- < ul key = "default-slot-container" >
268
- < slot />
269
- </ ul >
270
- ) ;
271
- }
272
-
273
- return null ;
262
+ return (
263
+ < ul hidden = { ! this . hasContent } key = "default-slot-container" >
264
+ < slot onSlotchange = { this . handleDefaultSlotChange } />
265
+ </ ul >
266
+ ) ;
274
267
}
275
268
276
269
render ( ) : VNode {
0 commit comments