Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(select): [select] fix component error caused by vue2 deep cleanup memory leak #2843

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/renderless/src/option/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const initState = ({ reactive, computed, props, api, markRaw, select, parent })
disabled: computed(() => props.disabled || state.groupDisabled),
isObject: computed(() => Object.prototype.toString.call(props.value).toLowerCase() === '[object object]'),
currentLabel: computed(() => props.label || (state.isObject ? '' : props.value)),
currentValue: computed(() => props.value || props.label || ''),
currentValue: props.value || props.label || '',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from computed to a direct assignment for currentValue may lead to unexpected behavior if currentValue is expected to reactively update based on dependencies. Ensure that this change does not break reactive updates elsewhere in the component.


itemSelected: computed(() => {
if (!select.multiple) {
Expand Down Expand Up @@ -90,7 +90,7 @@ const initWatch = ({ watch, props, state, select, constants }) => {
() => props.value,
(value, oldVal) => {
const { remote, valueKey } = select

state.currentValue = value || props.label || ''
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Handle edge case where value is 0.

The fallback chain value || props.label || '' will treat 0 as falsy and fall back to props.label. This might not be the desired behavior if 0 is a valid value.

Consider this alternative implementation:

-      state.currentValue = value || props.label || ''
+      state.currentValue = value != null ? value : props.label || ''
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
state.currentValue = value || props.label || ''
state.currentValue = value != null ? value : props.label || ''

if (!props.created && !remote) {
if (
valueKey &&
Expand Down
Loading