Skip to content

Commit

Permalink
Merge pull request #870 from lokesh-sagi125/develop
Browse files Browse the repository at this point in the history
make ui menu accept maxWidth to avoid text truncation
  • Loading branch information
AlexVelezLl authored Jan 28, 2025
2 parents a2c487b + fbc72c1 commit 7d0726a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/KDropdownMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
ref="menu"
:options="options"
:hasIcons="hasIcons"
:maxWidth="maxWidth"
@select="handleSelection"
/>
</UiPopover>
Expand Down Expand Up @@ -83,6 +84,11 @@
type: Boolean,
default: false,
},
/** Maximum width for the dropdown menu*/
maxWidth: {
type: [Number, String],
default: null,
},
/**
* The position of the dropdown relative to the button
*/
Expand Down
14 changes: 14 additions & 0 deletions lib/keen/UiMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
lazy

:class="classes"
:style="getWidth"
>
<UiMenuOption
v-for="(option, index) in options"
Expand Down Expand Up @@ -59,6 +60,10 @@
type: Boolean,
default: false,
},
maxWidth: {
type: [Number,String],
default: null,
},
iconProps: Object,
hasSecondaryText: {
type: Boolean,
Expand Down Expand Up @@ -101,6 +106,15 @@
'has-secondary-text': this.hasSecondaryText,
};
},
getWidth() {
if (this.maxWidth){
return {
maxWidth: this.maxWidth &&
(typeof this.maxWidth === 'number' ? `${this.maxWidth}px` : this.maxWidth)
};
}
return {};
},
activeOutline() {
return this.isActive ? this.$coreOutline : {};
},
Expand Down

0 comments on commit 7d0726a

Please sign in to comment.