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

[Draft][Do not merge]Convert sidebar from paper-listbox to mwc-list #7326

Conversation

donkawechico
Copy link
Contributor

@donkawechico donkawechico commented Oct 12, 2020

Proposed change

Change sidebar to use mwc-list instead of paper-listbox.

This fixes an issue with quick bar where shortcuts won't work if you click on the left nav at all (because iron behaviors have a bug where it stops propagation of keyboard events: PolymerElements/iron-menu-behavior#56)

sidebar_mwclist_1

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@donkawechico donkawechico changed the title Convert sidebar from paper-listbox to mwc-list [Draft][Do not merge]Convert sidebar from paper-listbox to mwc-list Oct 12, 2020
@donkawechico
Copy link
Contributor Author

Needed before merging

  • Need some folks to test for feature parity:
    • Editing / Reordering / Hiding
    • Collapsed / Narrow views
    • Tooltips
    • Navigation
    • Other?
  • Stylings do not yet match existing styles. Should they? Or should we keep consistent with as many mwc-list defaults as possible
  • Find and remove unnecessary code/stylings that were there to work around paper-listbox behaviors

${this.editMode && this._hiddenPanels.length
? html`
${this._hiddenPanels.map((url) => {
const panel = this.hass.panels[url];
if (!panel) {
return "";
}
return html`<paper-icon-item
return html`<mwc-list-item
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use graphic="icon" here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then update the slot of the item to slot="graphic

@click=${this._handleExternalAppConfiguration}
@mouseenter=${this._itemMouseEnter}
@mouseleave=${this._itemMouseLeave}
>
<ha-svg-icon
slot="item-icon"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
slot="item-icon"
slot="graphic"

@mouseleave=${this._itemMouseLeave}
>
<paper-icon-item>
<mwc-list-item>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use graphic="icon" here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<mwc-list-item>
<mwc-list-item

<ha-svg-icon slot="graphic" .path=${mdiBell}></ha-svg-icon>
${!this.expanded && notificationCount > 0
? html`
<span class="notification-badge" slot="graphic">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<span class="notification-badge" slot="graphic">
<span class="notification-badge">

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? not sure

: ""}
${hass.localize("ui.notification_drawer.title")}
${this.expanded && notificationCount > 0
? html` <span class="notification-badge">${notificationCount}</span> `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
? html` <span class="notification-badge">${notificationCount}</span> `
? html`<span class="notification-badge">${notificationCount}</span>`

></ha-user-badge>
${hass.user ? hass.user.name : ""}
</mwc-list-item>
<mwc-list-item disabled class="bottom-spacer"></mwc-list-item>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that, but I assumed that dividers were just the little <hr /> lines inbetween list items. I'll play with that.

class="ha-scrollbar"
.selected=${hass.panelUrl}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should set activated on the panel that is active

Copy link
Contributor Author

@donkawechico donkawechico Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already does this. The mwc-list-items have the .activated=${urlPath === this.hass.panelUrl} in their props.

image

>
<paper-icon-item>
<mwc-list-item>
<a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anchor should be outside of the item, you can no longer right click and open in a new tab now. Also keyboard navigation doesn't work now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting the anchor outside the item restores right-click, but arrowing down is still broken. It just scrolls down the sidebar but doesn't highlight any of the items.

Still looking into it, but nothing's obviously wrong. I may just need to start over from dev as I'm not sure what all I changed in order to make the buttons work without the anchor tag

</paper-icon-item>
</div>

<a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anchor should not be removed, it removes functionality

@donkawechico
Copy link
Contributor Author

donkawechico commented Nov 1, 2020

Closing this PR as the overall approach has changed radically. I've put up a new Draft PR for my own reference, and also so I can have early ad-hoc discussions with other devs when I need some help: #7573. At the time of this writing, it is not worth reviewing as it's full of junk and unused code.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants