-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(shell-center-row): fix rendering tied to named-slot content #10451
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
import { Component, Element, Fragment, h, Prop, VNode } from "@stencil/core"; | ||
import { | ||
ConditionalSlotComponent, | ||
connectConditionalSlotComponent, | ||
disconnectConditionalSlotComponent, | ||
} from "../../utils/conditionalSlot"; | ||
import { getSlotted } from "../../utils/dom"; | ||
import { Component, Element, Fragment, h, Prop, State, VNode } from "@stencil/core"; | ||
import { Position, Scale } from "../interfaces"; | ||
import { slotChangeGetAssignedElements } from "../../utils/dom"; | ||
import { CSS, SLOTS } from "./resources"; | ||
|
||
/** | ||
|
@@ -17,7 +12,7 @@ import { CSS, SLOTS } from "./resources"; | |
styleUrl: "shell-center-row.scss", | ||
shadow: true, | ||
}) | ||
export class ShellCenterRow implements ConditionalSlotComponent { | ||
export class ShellCenterRow { | ||
// -------------------------------------------------------------------------- | ||
// | ||
// Properties | ||
|
@@ -47,19 +42,7 @@ export class ShellCenterRow implements ConditionalSlotComponent { | |
|
||
@Element() el: HTMLCalciteShellCenterRowElement; | ||
|
||
// -------------------------------------------------------------------------- | ||
// | ||
// Lifecycle | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
connectedCallback(): void { | ||
connectConditionalSlotComponent(this); | ||
} | ||
|
||
disconnectedCallback(): void { | ||
disconnectConditionalSlotComponent(this); | ||
} | ||
@State() actionBar: HTMLCalciteActionBarElement; | ||
|
||
// -------------------------------------------------------------------------- | ||
// | ||
|
@@ -68,28 +51,33 @@ export class ShellCenterRow implements ConditionalSlotComponent { | |
// -------------------------------------------------------------------------- | ||
|
||
render(): VNode { | ||
const { el } = this; | ||
const { actionBar } = this; | ||
|
||
const contentNode = ( | ||
<div class={CSS.content}> | ||
<slot /> | ||
</div> | ||
); | ||
|
||
const actionBar = getSlotted<HTMLCalciteActionBarElement>(el, SLOTS.actionBar); | ||
|
||
const actionBarNode = actionBar ? ( | ||
<div class={CSS.actionBarContainer} key="action-bar"> | ||
<slot name={SLOTS.actionBar} /> | ||
const actionBarNode = ( | ||
<div class={CSS.actionBarContainer} hidden={!this.actionBar} key="action-bar"> | ||
<slot name={SLOTS.actionBar} onSlotchange={this.handleActionBarSlotChange} /> | ||
</div> | ||
) : null; | ||
); | ||
|
||
const children: VNode[] = [actionBarNode, contentNode]; | ||
|
||
// todo: if actionBar position changes, this will not update. | ||
if (actionBar?.position === "end") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you create a separate issue for this and remove this comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I can create one. Didn't we decide to deprecate shell-center-row at some point? |
||
children.reverse(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if actionBar position changes, this will not update. Since this component is deprecated I guess it doesn't matter too much. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
return <Fragment>{children}</Fragment>; | ||
} | ||
|
||
private handleActionBarSlotChange = (event: Event): void => { | ||
this.actionBar = slotChangeGetAssignedElements(event).filter( | ||
(el): el is HTMLCalciteActionBarElement => el.matches("calcite-action-bar"), | ||
)[0]; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
page.waitForChanges
shouldn't be necessary after setting the test content. 🤔