Skip to content

Commit

Permalink
Release319 fix(transfer): fix drag 2 item to right when set filterabl…
Browse files Browse the repository at this point in the history
…e=true (#2517)

* fix(transfer): fix drag 2 item to right when set filterable=true

* fix(renderlese): update version
  • Loading branch information
shenjunjian authored Nov 12, 2024
1 parent c1496ee commit cd67330
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/renderless/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/vue-renderless",
"version": "3.19.4",
"version": "3.19.5",
"private": true,
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
"author": "OpenTiny Team",
Expand Down
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 cd67330

Please sign in to comment.