tusen-ai / naive-ui

A Vue 3 Component Library. Fairly Complete. Theme Customizable. Uses TypeScript. Fast.

Home Page:https://www.naiveui.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto Complete放进 Modal时有错位问题

onlyJinx opened this issue · comments

描述错误

如图(右下角)

bandicam 2024-04-17 23-41-16-000

复现步骤

<template>
  <n-button @click="showModal = true"> 来吧 </n-button>
  <n-modal v-model:show="showModal">
    <n-card
      style="width: 600px"
      title="模态框"
      :bordered="false"
      size="huge"
      role="dialog"
      aria-modal="true"
    >
      <n-auto-complete
        v-model:value="value"
        :input-props="{
          autocomplete: 'disabled',
        }"
        :options="options"
        placeholder="邮箱"
        clearable
      />
    </n-card>
  </n-modal>
</template>

<script lang="ts">
import { defineComponent, ref,computed } from "vue";

export default defineComponent({
  setup() {
  const valueRef = ref('')
    return {
      value: valueRef,
      options: computed(() => {
        return ['@gmail.com', '@163.com', '@qq.com'].map((suffix) => {
          const prefix = valueRef.value.split('@')[0]
          return {
            label: prefix + suffix,
            value: prefix + suffix
          }
        })
      })
      showModal: ref(false),
    };
  },
});
</script>

最小复现链接

https://codesandbox.io/p/sandbox/ancient-star-gjr633

系统信息

不是系统问题

使用的包管理器

npm

验证

是由于 autoFocus 导致的,解决办法两种:

  1. 设置 preset
  2. auto-focus 设为 false

Simalar to #4756 (comment)

是由于 autoFocus 导致的,解决办法两种:

  1. 设置 preset
  2. auto-focus 设为 false

Simalar to #4756 (comment)

OK,设置了 auto-focus 后可以解决,谢谢啦