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

Use one-way binding for the browser picker #3720

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
11 changes: 7 additions & 4 deletions webapp/components/browser-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BrowserPicker extends ProductInfo(PolymerElement) {
static get template() {
return html`
<paper-dropdown-menu label="Browser" no-animations>
<paper-listbox slot="dropdown-content" selected="{{ browser }}" attr-for-selected="value">
<paper-listbox slot="dropdown-content" selected="[[browser]]" attr-for-selected="value" on-change="selectedChanged">
<template is="dom-repeat" items="[[products]]" as="product">
<paper-icon-item value="[[product.browser_name]]">
<display-logo slot="item-icon" product="[[product]]" small></display-logo>
Expand All @@ -33,14 +33,19 @@ class BrowserPicker extends ProductInfo(PolymerElement) {
browser: {
type: String,
value: DefaultBrowserNames[0],
notify: true,
},
products: {
type: Array,
value: DefaultProducts.map(p => Object.assign({}, p)),
},
};
}

selectedChanged(e) {
this.dispatchEvent(new CustomEvent('browser-name-changed', {
detail: { value: e.target.value }
}));
}
}
window.customElements.define(BrowserPicker.is, BrowserPicker);
export { BrowserPicker };
Expand Down Expand Up @@ -84,7 +89,6 @@ class BrowserMultiPicker extends ProductInfo(PolymerElement) {
browser: {
type: String,
value: DefaultBrowserNames[0],
notify: true,
},
products: {
type: Array,
Expand All @@ -93,7 +97,6 @@ class BrowserMultiPicker extends ProductInfo(PolymerElement) {
},
selected: {
type: Array,
notify: true,
value: DefaultProducts.map(p => p.browser_name),
}
};
Expand Down
Loading