Skip to content

Commit

Permalink
fix(Select): fix render when using virtual scroll with custom label (#…
Browse files Browse the repository at this point in the history
…4677)

* fix(Select): fix label render when using virtual scroll with custom label

* chore: fix before unmount

* fix(select): fix filterable behavior when pressing enter

* chore: comment
  • Loading branch information
uyarn authored Oct 26, 2024
1 parent d556760 commit e933f42
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/select-input/select-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default defineComponent({
});

onBeforeUnmount(() => {
selectInputRef.value.removeEventListener('keydown', addKeyboardEventListener);
selectInputRef.value?.removeEventListener('keydown', addKeyboardEventListener);
});

const onOverlayClick: PopupProps['onOverlayClick'] = (ctx) => {
Expand Down
2 changes: 1 addition & 1 deletion src/select/hooks/useKeyboardControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default function useKeyboardControl({
watch(hoverIndex, (index) => {
const optionHeight = selectPanelRef.value?.innerRef?.querySelector(
`.${classPrefix.value}-select-option`,
).clientHeight;
)?.clientHeight;

const scrollHeight = optionHeight * index;

Expand Down
3 changes: 0 additions & 3 deletions src/select/option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ export default defineComponent({
trigger: val ? 'check' : 'uncheck',
e: context.e,
});
if (!selectProvider.value.reserveKeyword) {
selectProvider.value.handlerInputChange('');
}
};

const renderTitle = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/select/select-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default defineComponent({
scrollType: props.scroll?.type,
isVirtual: isVirtual.value,
bufferSize: props.scroll?.bufferSize,
key: `${item.$index || ''}_${index}`,
key: `${item.$index || ''}_${index}_${item.value}`,
}
: {
key: `${index}_${item.value}`,
Expand Down
4 changes: 3 additions & 1 deletion src/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default defineComponent({
newVal = props.multiple ? (newVal as SelectValue[]).map((val) => getOption(val)) : getOption(newVal);
}
if (newVal === orgValue.value) return;
if (props.multiple && !props.reserveKeyword) setInputValue('');
setOrgValue(newVal, {
selectedOptions: getSelectedOptions(newVal),
...context,
Expand Down Expand Up @@ -167,7 +168,8 @@ export default defineComponent({
const handleCreate = () => {
if (!innerInputValue.value) return;
props.onCreate?.(innerInputValue.value);
setInputValue('');
// only clean input value when reopen popup
if (!innerPopupVisible.value) setInputValue('');
};

const popupContentRef = computed(() => selectInputRef.value?.popupRef.getOverlay() as HTMLElement);
Expand Down

0 comments on commit e933f42

Please sign in to comment.