Skip to content

Commit

Permalink
fix: column drop position
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Mar 2, 2020
1 parent f76cafb commit 9c2d83d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/js/components/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ export default class Component extends Data {
if (isInt(delItem)) {
parent.splice(Number(delItem), 1)
} else {
this.set(
delPath,
parent.filter(item => item !== delItem)
)
this.set(delPath, parent.filter(item => item !== delItem))
}
} else {
delete parent[delItem]
Expand Down Expand Up @@ -321,12 +318,11 @@ export default class Component extends Data {
* @param {Object} evt
* @return {Object} Component
*/
onAdd({ from, to, item }) {
onAdd({ from, to, item, newIndex }) {
const _this = this
if (!from.classList.contains(CONTROL_GROUP_CLASSNAME)) {
from = from.parentElement
}
const newIndex = indexOfNode(item, to)
const fromType = componentType(from)
const toType = componentType(to.parentElement)
const defaultOnAdd = () => {
Expand Down Expand Up @@ -400,7 +396,7 @@ export default class Component extends Data {
column: 1,
}
const action = (depthMap.get(targets[toType]) || identity)()
return action && action(item.id)
return action && action({ id: item.id }, newIndex)
},
column: () => {
const targets = {
Expand Down
7 changes: 5 additions & 2 deletions src/js/components/rows/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dom from '../../common/dom'
import events from '../../common/events'
import { bsGridRegEx } from '../../common/helpers'
import { numToPercent } from '../../common/utils'
import { ROW_CLASSNAME, COLUMN_TEMPLATES, ANIMATION_SPEED_BASE, COLUMN_CLASSNAME } from '../../constants'
import { ROW_CLASSNAME, COLUMN_TEMPLATES, ANIMATION_SPEED_FAST, COLUMN_CLASSNAME } from '../../constants'
import { removeCustomOption } from '../columns/events'

const DEFAULT_DATA = () =>
Expand Down Expand Up @@ -194,7 +194,10 @@ export default class Row extends Component {
column.set('config.width', newColWidth)
colDom.style.width = newColWidth
colDom.dataset.colWidth = newColWidth
setTimeout(column.refreshFieldPanels, ANIMATION_SPEED_BASE)
const refreshTimeout = setTimeout(() => {
clearTimeout(refreshTimeout)
column.refreshFieldPanels()
}, ANIMATION_SPEED_FAST)
document.dispatchEvent(events.columnResized)
})
this.updateColumnPreset()
Expand Down

0 comments on commit 9c2d83d

Please sign in to comment.