-
+
>(null)
const visible = ref(false)
+ const scrollbar = ref(null)
+ const wrapStyle = computed(() => `max-height: ${addUnit(props.maxHeight)}`)
+
watch(
() => visible.value,
val => {
@@ -187,11 +204,13 @@ export default defineComponent({
function triggerElmFocus() {
triggerElm.value?.focus?.()
}
+
function triggerElmBlur() {
triggerElm.value?.blur?.()
}
const dropdownSize = computed(() => props.size || ELEMENT.size)
+
function commandHandler(...args) {
emit('command', ...args)
}
@@ -247,6 +266,8 @@ export default defineComponent({
return {
visible,
+ scrollbar,
+ wrapStyle,
dropdownSize,
handlerMainButtonClick,
triggerVnode,
diff --git a/packages/theme-chalk/src/common/var.scss b/packages/theme-chalk/src/common/var.scss
index 056a0bcdc2..260aa83cc0 100644
--- a/packages/theme-chalk/src/common/var.scss
+++ b/packages/theme-chalk/src/common/var.scss
@@ -741,6 +741,7 @@ $--tree-expand-icon-color: $--color-text-placeholder !default;
$--dropdown-menu-box-shadow: $--box-shadow-light !default;
$--dropdown-menuItem-hover-fill: $--color-primary-light-9 !default;
$--dropdown-menuItem-hover-color: $--link-color !default;
+$--dropdown-menu-index: 10 !default;
/* Badge
-------------------------- */
diff --git a/packages/theme-chalk/src/dropdown.scss b/packages/theme-chalk/src/dropdown.scss
index 6ca2ce0d10..1c47fcccff 100644
--- a/packages/theme-chalk/src/dropdown.scss
+++ b/packages/theme-chalk/src/dropdown.scss
@@ -13,9 +13,9 @@
// using attributes selector to override
@include picker-popper(
- $--color-white,
- 1px solid $--border-color-light,
- $--dropdown-menu-box-shadow,
+ $--color-white,
+ 1px solid $--border-color-light,
+ $--dropdown-menu-box-shadow,
);
.#{$namespace}-dropdown-menu {
@@ -25,10 +25,22 @@
#{& + '-selfdefine'} {
outline: none;
}
+
+ @include b(scrollbar__bar) {
+ z-index: #{$--dropdown-menu-index + 1};
+ }
+
+ @include b(dropdown__list) {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ box-sizing: border-box;
+ }
}
.#{$namespace}-button-group {
display: block;
+
.#{$namespace}-button {
float: none;
}
@@ -82,7 +94,7 @@
position: relative;
top: 0;
left: 0;
- z-index: 10;
+ z-index: $--dropdown-menu-index;
padding: 10px 0;
margin: 0;
background-color: $--color-white;
diff --git a/website/docs/en-US/dropdown.md b/website/docs/en-US/dropdown.md
index 74ccec8012..2effbce07c 100644
--- a/website/docs/en-US/dropdown.md
+++ b/website/docs/en-US/dropdown.md
@@ -306,12 +306,12 @@ Besides default size, Dropdown component provides three additional sizes for you
```
:::
-
### Dropdown Attributes
| Attribute | Description | Type | Accepted Values | Default |
|------------- |---------------- |---------------- |---------------------- |-------- |
| type | menu button type, refer to `Button` Component, only works when `split-button` is true | string | — | — |
| size | menu size, also works on the split button | string | medium / small / mini | — |
+| max-height | the max height of menu | string / number | — | — |
| split-button | whether a button group is displayed | boolean | — | false |
| placement | placement of pop menu | string | top/top-start/top-end/bottom/bottom-start/bottom-end | bottom-end |
| trigger | how to trigger | string | hover/click/contextmenu | hover |
diff --git a/website/docs/es/dropdown.md b/website/docs/es/dropdown.md
index c91dad8b8e..9a9f774fff 100644
--- a/website/docs/es/dropdown.md
+++ b/website/docs/es/dropdown.md
@@ -307,12 +307,12 @@ Además del tamaño predeterminado, el componente Dropdown proporciona tres tama
```
:::
-
### Dropdown atributos
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
| ------------- | ---------------------------------------- | ------- | ---------------------------------------- | ----------- |
| type | tipo de botón de menú, consulte Componente`Button`, sólo funciona cuando `split-button` es true. | string | — | — |
| size | tamaño del menú, también funciona en `split-button` | string | medium / small / mini | — |
+| max-height | the max height of menu | string / number | — | — |
| split-button | si se visualiza un grupo de botones | boolean | — | false |
| placement | colocación del menú | string | top/top-start/top-end/bottom/bottom-start/bottom-end | bottom-end |
| trigger | cómo detonar | string | hover/click/contextmenu | hover |
diff --git a/website/docs/fr-FR/dropdown.md b/website/docs/fr-FR/dropdown.md
index 594c7016ec..edffac1b7a 100644
--- a/website/docs/fr-FR/dropdown.md
+++ b/website/docs/fr-FR/dropdown.md
@@ -306,13 +306,13 @@ En plus de la taille par défaut, le composant Dropdown propose trois autres tai
```
:::
-
### Attributs du Dropdown
| Attribut | Description | Type | Valeurs acceptées | Défaut |
|------------- |---------------- |---------------- |---------------------- |-------- |
| type | Type du bouton, se référer au composant `Button`. Ne marche que si `split-button` est `true`. | string | — | — |
| size | Taille du menu, marche aussi avec `split button`. | string | medium / small / mini | — |
+| max-height | the max height of menu | string / number | — | — |
| split-button | Si le bouton est séparé en deux. | boolean | — | false |
| placement | Emplacement du menu déroulant | string | top/top-start/top-end/bottom/bottom-start/bottom-end | bottom-end |
| trigger | Comment déclencher l'ouverture du menu. | string | hover/click/contextmenu | hover |
diff --git a/website/docs/jp/dropdown.md b/website/docs/jp/dropdown.md
index 0b44c807a3..ec5858b306 100644
--- a/website/docs/jp/dropdown.md
+++ b/website/docs/jp/dropdown.md
@@ -305,12 +305,12 @@ dropdownリストを起動するには、ボタンを使用します。
```
:::
-
### dropdown属性
| Attribute | Description | Type | Accepted Values | Default |
|------------- |---------------- |---------------- |---------------------- |-------- |
| type | `split-button` が `true`のとき、メニューボタンのタイプは `Button` コンポーネントを参照する。 | string | — | — |
| size | メニューのサイズ(分割ボタンでも動作) | string | medium / small / mini | — |
+| max-height | the max height of menu | string / number | — | — |
| split-button | ボタングループの表示の有無 | boolean | — | false |
| placement | ポップメニューの配置 | string | top/top-start/top-end/bottom/bottom-start/bottom-end | bottom-end |
| trigger | トリガーのきっかけ | string | hover/click/contextmenu | hover |
diff --git a/website/docs/zh-CN/dropdown.md b/website/docs/zh-CN/dropdown.md
index a1ca6d19db..28673a2859 100644
--- a/website/docs/zh-CN/dropdown.md
+++ b/website/docs/zh-CN/dropdown.md
@@ -315,6 +315,7 @@ Dropdown 组件提供除了默认值以外的三种尺寸,可以在不同场
|------------- |---------------- |---------------- |---------------------- |-------- |
| type | 菜单按钮类型,同 Button 组件(只在`split-button`为 true 的情况下有效) | string | — | — |
| size | 菜单尺寸,在`split-button`为 true 的情况下也对触发按钮生效 | string | medium / small / mini | — |
+| max-height | 菜单最大高度 | string / number | — | — |
| split-button | 下拉触发元素呈现为按钮组 | boolean | — | false |
| placement | 菜单弹出位置 | string | top/top-start/top-end/bottom/bottom-start/bottom-end | bottom-end |
| trigger | 触发下拉的行为 | string | hover, click, contextmenu | hover |