Skip to content

Commit

Permalink
fix(ui5-shellbar): do not duplicate popover menu items (#1456)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladitasev committed Apr 9, 2020
1 parent b0505ce commit ae20272
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion packages/base/src/UI5Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,22 @@ class UI5Element extends HTMLElement {
throw new Error(`"${prop}" is not a valid property name. Use a name that does not collide with DOM APIs`);
}

if (propData.type === "boolean" && propData.defaultValue) {
if (propData.type === Boolean && propData.defaultValue) {
throw new Error(`Cannot set a default value for property "${prop}". All booleans are false by default.`);
}

if (propData.type === Array) {
throw new Error(`Wrong type for property "${prop}". Properties cannot be of type Array - use "multiple: true" and set "type" to the single value type, such as "String", "Object", etc...`);
}

if (propData.type === Object && propData.defaultValue) {
throw new Error(`Cannot set a default value for property "${prop}". All properties of type "Object" are empty objects by default.`);
}

if (propData.multiple && propData.defaultValue) {
throw new Error(`Cannot set a default value for property "${prop}". All multiple properties are empty arrays by default.`);
}

Object.defineProperty(proto, prop, {
get() {
if (this._state[prop] !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions packages/fiori/src/ShellBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ const metadata = {
},

_menuPopoverItems: {
type: Array,
defaultValue: [],
type: String,
multiple: true,
},
},
managedSlots: true,
Expand Down

0 comments on commit ae20272

Please sign in to comment.