Skip to content

Commit

Permalink
fix(transfer): fix drag 2 item to right when set filterable=true
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjunjian committed Nov 7, 2024
1 parent 1ed1721 commit 8f38804
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions packages/renderless/src/transfer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

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]
const index = isAdd ? state.rightChecked.indexOf(key) : state.leftChecked.indexOf(key)
const valueIndex = currentValue.indexOf(key)

Expand Down
4 changes: 2 additions & 2 deletions packages/renderless/src/transfer/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const initState = ({ reactive, computed, api, props, h, slots }): ITransferState
export const renderless = (
props: ITransferProps,
{ computed, onMounted, reactive, h }: ISharedRenderlessParamHooks,
{ $prefix, emit, refs, parent, slots }: ITransferRenderlessParamUtils
{ $prefix, emit, refs, parent, slots, vm }: ITransferRenderlessParamUtils
) => {
const api = {} as ITransferApi
const Tree = $prefix + 'Tree'
Expand All @@ -80,7 +80,7 @@ export const renderless = (
addToRight: addToRight({ emit, refs, props, state, Tree }),
onTargetCheckedChange: onTargetCheckedChange({ emit, state }),
onSourceCheckedChange: onSourceCheckedChange({ emit, state }),
logicFun: logicFun({ props, emit, state }),
logicFun: logicFun({ props, emit, state, vm }),
getTargetData: getTargetData({ props, state, Tree, Table }),
sortableEvent: sortableEvent({ api, droppanel: DROPPANEL, props, queryDom: TRANSFERPANEL, refs })
})
Expand Down

0 comments on commit 8f38804

Please sign in to comment.