Skip to content

Commit 6604eca

Browse files
committed
fixed open-by-default issue
Signed-off-by: Maximilian Inckmann <[email protected]>
1 parent 8071137 commit 6604eca

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

packages/stencil-library/src/components/pid-collapsible/collapsible.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pid-collapsible.resize-both {
3232
max-width: 100% !important; /* Prevent exceeding parent container */
3333
will-change: width, height; /* Hint to the browser to optimize for resizing */
3434
transition: none !important; /* Disable transitions during resize for better performance */
35+
min-height: fit-content; /* Ensure the component expands to fit its content */
36+
min-width: fit-content; /* Ensure the component expands to fit its content */
3537
}
3638

3739
/*

packages/stencil-library/src/components/pid-collapsible/pid-collapsible.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ export class PidCollapsible {
338338
if (!this.currentHeight || this.currentHeight === `${this.lineHeight}px`) {
339339
this.currentHeight = this.initialHeight || `${optimalHeight}px`;
340340
} else {
341+
// Set the height to exactly match the content height plus padding
341342
this.currentHeight = `${optimalHeight}px`;
342343
}
343344

packages/stencil-library/src/components/pid-component/pid-component.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,20 @@ export class PidComponent {
193193
// Initialize component ID for references
194194
this.ensureComponentId();
195195

196-
// Ensure collapsible gets proper initial width after load
196+
// Ensure collapsible gets proper initial width and open state after load
197197
setTimeout(() => {
198198
const collapsible = this.el.querySelector('pid-collapsible');
199-
if (collapsible && typeof (collapsible as any).recalculateContentDimensions === 'function') {
200-
(collapsible as any).recalculateContentDimensions();
199+
if (collapsible) {
200+
// Set open state explicitly based on openByDefault property
201+
if (this.openByDefault) {
202+
(collapsible as any).open = true;
203+
(collapsible as any).expanded = true;
204+
}
205+
206+
// Recalculate dimensions after setting open state
207+
if (typeof (collapsible as any).recalculateContentDimensions === 'function') {
208+
(collapsible as any).recalculateContentDimensions();
209+
}
201210
}
202211
}, 0);
203212
}

0 commit comments

Comments
 (0)