Skip to content

Commit 4d20db0

Browse files
committed
fix(select): adjust padding and layout for better alignment
1 parent e68b397 commit 4d20db0

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

packages/varlet-ui/src/field-decorator/fieldDecorator.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
.var-field-decorator {
6868
position: relative;
6969
width: 100%;
70-
overflow: hidden;
7170
color: var(--field-decorator-text-color);
7271

7372
&__controller {

packages/varlet-ui/src/select/Select.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
v-if="isShowMultipleInput()"
8989
ref="inputRef"
9090
v-model="pattern"
91-
:style="inputStyle"
91+
:style="{ ...inputStyle, paddingLeft: labels.length ? '4px' : 0 }"
9292
:multiple="multiple"
9393
@focus="handleFocus"
9494
@blur="handleRootBlur"
@@ -216,7 +216,6 @@ export default defineComponent({
216216
const focusColor = computed(() => props.focusColor)
217217
const isEmptyModelValue = computed(() => isEmpty(props.modelValue))
218218
const cursor = computed(() => (props.disabled || props.readonly ? '' : 'pointer'))
219-
const offsetY = ref(0)
220219
const { bindForm, form } = useForm()
221220
const { length, options, bindOptions } = useOptions()
222221
const { label, labels, computeLabel, getSelectedValue } = useSelectController({
@@ -236,6 +235,20 @@ export default defineComponent({
236235
const disabled = computed(() => form?.disabled.value || props.disabled)
237236
const menuEl = ref<HTMLElement | null>(null)
238237
const menuRef = ref<InstanceType<typeof VarMenu> | null>(null)
238+
239+
let _offsetY = 0
240+
241+
const offsetY = computed({
242+
get() {
243+
// adaptive to the 1px line of standard variant when filterable is true
244+
return _offsetY + (props.filterable && props.variant === 'standard' ? 1 : 0)
245+
},
246+
247+
set(v) {
248+
_offsetY = v
249+
},
250+
})
251+
239252
const placement = computed(() => (props.variant === 'outlined' || props.filterable ? 'bottom' : 'cover-top'))
240253
const placeholderColor = computed(() => {
241254
const { hint, blurColor, focusColor } = props

packages/varlet-ui/src/select/select.less

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@
5656
transition: color 0.25s;
5757
}
5858

59-
&__values,
59+
&__values {
60+
display: flex;
61+
flex-wrap: wrap;
62+
align-items: center;
63+
}
64+
6065
&__chips {
6166
display: flex;
6267
flex-wrap: wrap;
@@ -79,7 +84,6 @@
7984

8085
&--multiple {
8186
position: unset;
82-
padding-left: 4px;
8387
}
8488
}
8589

0 commit comments

Comments
 (0)