Skip to content

add option to disable pre-selects of first dropdown item in n-auto-complete #6797

@lanyeeee

Description

@lanyeeee

Clear and concise description of the problem

Currently, the n-auto-complete always pre-selects the first option in the dropdown list, which means pressing Enter will automatically select this option.

While this behavior is useful in many cases, there are scenarios where developers might want to disable this auto-pending behavior to give users more explicit control over their selections.

Suggested solution

In the n-auto-complete component, we can add a new boolean prop called auto-pending which defaults to true to maintain backward compatibility:

autoPending: {
  type: Boolean,
  default: true
}

Then we can pass this prop to the internal select menu component:

<NInternalSelectMenu
  // other props
  autoPending={this.autoPending}
  // other props
/>

This allows users to disable the automatic pre-selection of the first option by setting auto-pending="false" on the component:

<n-auto-complete
  v-model:value="value"
  :options="options"
  :auto-pending="false"
/>

Alternative

No response

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions