mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-18 10:59:10 +08:00
fix: [el-select-v2] avoid remove new option when reserve-keyword is true (#5912)
This commit is contained in:
parent
2ed6fc4cee
commit
f194efca96
@ -58,7 +58,14 @@ export function useAllowCreate(props: ISelectProps, states) {
|
||||
}
|
||||
|
||||
function removeNewOption(option: Option) {
|
||||
if (!enableAllowCreateMode.value || !option || !option.created) {
|
||||
if (
|
||||
!enableAllowCreateMode.value ||
|
||||
!option ||
|
||||
!option.created ||
|
||||
(option.created &&
|
||||
props.reserveKeyword &&
|
||||
states.inputValue === option.label)
|
||||
) {
|
||||
return
|
||||
}
|
||||
const idx = states.createdOptions.findIndex(
|
||||
|
@ -591,7 +591,10 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
const onKeyboardSelect = () => {
|
||||
if (!expanded.value) {
|
||||
return toggleMenu()
|
||||
} else if (~states.hoveringIndex) {
|
||||
} else if (
|
||||
~states.hoveringIndex &&
|
||||
filteredOptions.value[states.hoveringIndex]
|
||||
) {
|
||||
onSelect(
|
||||
filteredOptions.value[states.hoveringIndex],
|
||||
states.hoveringIndex,
|
||||
|
Loading…
Reference in New Issue
Block a user