-
Notifications
You must be signed in to change notification settings - Fork 331
Release319 fix(transfer): fix drag 2 item to right when set filterable=true #2517
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,17 +217,20 @@ export const clearQuery = (refs: ITransferRenderlessParams['refs']) => (which: ' | |
|
|
||
| /** SortableJs 插件的回调逻辑, 添加,删除,更新事件后,触发本函数 */ | ||
| export const logicFun = | ||
| ({ props, emit, state }: Pick<ITransferRenderlessParams, 'emit' | 'props' | 'state'>) => | ||
| ({ props, emit, state, vm }: Pick<ITransferRenderlessParams, 'emit' | 'props' | 'state'>) => | ||
| ({ event, isAdd, pullMode }: { event: any; isAdd?: boolean; pullMode?: 'sort' }) => { | ||
| let currentValue = props.modelValue.slice() | ||
| let movedKeys = [] | ||
|
|
||
| if (pullMode) { | ||
| currentValue.splice(event.newIndex, 0, currentValue.splice(event.oldIndex, 1)[0]) | ||
| } else { | ||
| const rightPanel = vm.$refs.rightPanel | ||
| const leftPanel = vm.$refs.leftPanel | ||
|
|
||
|
Comment on lines
+228
to
+230
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null checks for panel refs The panel refs should be checked for null to prevent runtime errors. Apply this fix: - const rightPanel = vm.$refs.rightPanel
- const leftPanel = vm.$refs.leftPanel
+ const rightPanel = vm.$refs.rightPanel
+ const leftPanel = vm.$refs.leftPanel
+
+ if (!rightPanel?.state?.filteredData || !leftPanel?.state?.filteredData) {
+ return
+ }
|
||
| const key = isAdd | ||
| ? state.targetData[event.oldIndex][props.props.key] | ||
| : state.sourceData[event.oldIndex][props.props.key] | ||
| ? rightPanel.state.filteredData[event.oldIndex][props.props.key] | ||
| : leftPanel.state.filteredData[event.oldIndex][props.props.key] | ||
|
Comment on lines
+232
to
+233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add bounds check for array access The array access using Apply this fix: - ? rightPanel.state.filteredData[event.oldIndex][props.props.key]
- : leftPanel.state.filteredData[event.oldIndex][props.props.key]
+ ? (rightPanel.state.filteredData[event.oldIndex] || {})[props.props.key]
+ : (leftPanel.state.filteredData[event.oldIndex] || {})[props.props.key]Additionally, consider adding validation: + if (event.oldIndex < 0 ||
+ (isAdd && event.oldIndex >= rightPanel.state.filteredData.length) ||
+ (!isAdd && event.oldIndex >= leftPanel.state.filteredData.length)) {
+ return
+ }
|
||
| const index = isAdd ? state.rightChecked.indexOf(key) : state.leftChecked.indexOf(key) | ||
| const valueIndex = currentValue.indexOf(key) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update type annotation to include
vmparameterThe type annotation is missing the
vmparameter in thePicktype utility.Apply this fix:
📝 Committable suggestion