Skip to content
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(nav-drawer): Mini variant not initially visible #1267

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Mask input - after a form `reset` call correctly update underlying input value and placeholder state
- Tree - setting `--ig-size` on the item `indicator` CSS Part will now change the size of the icon
- Date-time input - double emit of `igcChange` in certain scenarios
- Navigation drawer - mini variant is not initially rendered when not in an open state [#1266](https://github.com/IgniteUI/igniteui-webcomponents/issues/1266)

## [4.9.0] - 2024-04-30
### Added
Expand Down
19 changes: 19 additions & 0 deletions src/components/nav-drawer/nav-drawer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,25 @@ describe('Navigation Drawer', () => {
computedStyles = window.getComputedStyle(mini);
expect(computedStyles.getPropertyValue('display')).to.not.equal('none');
});

it('initial render of a navbar with mini slot', async () => {
el = await fixture<IgcNavDrawerComponent>(html`
<igc-nav-drawer>
<div slot="mini">
<igc-nav-drawer-item>
<igc-icon slot="icon" name="home"></igc-icon>
</igc-nav-drawer-item>

<igc-nav-drawer-item>
<igc-icon slot="icon" name="search"></igc-icon>
</igc-nav-drawer-item>
</div>
</igc-nav-drawer>
`);

expect(el.open).to.be.false;
expect(el.renderRoot.querySelector<Element>('[part="mini"]')).to.exist;
});
});

const createNavDrawerElement = (
Expand Down
34 changes: 17 additions & 17 deletions src/components/nav-drawer/nav-drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import { styles as shared } from './themes/shared/container/nav-drawer.common.cs
*
* @element igc-nav-drawer
*
* @slot - The default slot for the drawer.
* @slot mini - The slot for the mini variant of the drawer.
* @slot - The default slot for the igc-navigation-drawer.
* @slot mini - The slot for the mini variant of the igc-navigation-drawer.
*
* @csspart base - The base wrapper of the navigation drawer.
* @csspart main - The main container.
* @csspart mini - The mini container.
* @csspart base - The base wrapper of the igc-navigation-drawer.
* @csspart main - The main container of the igc-navigation-drawer.
* @csspart mini - The mini container of the igc-navigation-drawer.
*/
@themes(all)
export default class IgcNavDrawerComponent extends LitElement {
Expand Down Expand Up @@ -54,6 +54,12 @@ export default class IgcNavDrawerComponent extends LitElement {
@property({ type: Boolean, reflect: true })
public open = false;

protected override createRenderRoot() {
const root = super.createRenderRoot();
root.addEventListener('slotchange', () => this.requestUpdate());
return root;
}

/** Opens the drawer. */
public show() {
if (this.open) {
Expand All @@ -74,21 +80,15 @@ export default class IgcNavDrawerComponent extends LitElement {

/** Toggles the open state of the drawer. */
public toggle() {
if (this.open) {
this.hide();
} else {
this.show();
}
this.open ? this.hide() : this.show();
}

private resolvePartNames(base: string) {
return {
[base]: true,
protected override render() {
const parts = partNameMap({
mini: true,
hidden: this._miniSlotElements.length < 1,
};
}
});

protected override render() {
return html`
<div part="overlay" @click=${this.hide}></div>

Expand All @@ -98,7 +98,7 @@ export default class IgcNavDrawerComponent extends LitElement {
</div>
</div>

<div part="${partNameMap(this.resolvePartNames('mini'))}">
<div part=${parts}>
<slot name="mini"></slot>
</div>
`;
Expand Down
Loading