Skip to content

Commit

Permalink
[Bug]: steedos-board组件的change事件在amis3.2环境下失效
Browse files Browse the repository at this point in the history
  • Loading branch information
tujiajun committed Nov 24, 2023
1 parent 126ecd0 commit f770d13
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ export function MultipleContainers(props) {
cardClassName = "",
}: Props = props

if(!props.data){
// 为了解决3.2 dispatchevent不生效的问题, https://github.com/baidu/amis/issues/7488
// 如果data为undefined,dispatchEvent时第三个参数传入的current的data为undefined会报错
props.data = {}
}
const MultipleContainersRef: any = useRef();

value && delete(value.$$id);

const [items, setItems] = useState<Items>(
Expand Down Expand Up @@ -244,7 +251,8 @@ export function MultipleContainers(props) {
'change',
createObject(amisData, {
value
})
}),
MultipleContainersRef.current
);
if (rendererEvent?.prevented) {
return;
Expand Down Expand Up @@ -374,7 +382,7 @@ export function MultipleContainers(props) {
});
}, [items]);

return (
let multipleContainers = (
<DndContext
sensors={sensors}
collisionDetection={collisionDetectionStrategy}
Expand Down Expand Up @@ -554,6 +562,7 @@ export function MultipleContainers(props) {
cancelDrop={cancelDrop}
onDragCancel={onDragCancel}
modifiers={modifiers}
{...props}//dispatchevent需要实例中的props有amis的各项属性,因此将所有props一起传下来
>
<div
style={{
Expand Down Expand Up @@ -654,6 +663,11 @@ export function MultipleContainers(props) {
</DndContext>
);

// 为了解决3.2 dispatchevent不生效的问题, https://github.com/baidu/amis/issues/7488
// dispatchEvent时第三个参数传入的current必须是一个带props属性的对象
MultipleContainersRef.current = multipleContainers;
return multipleContainers;

function renderSortableItemDragOverlay(id: UniqueIdentifier) {
const item = cloneDeep(keyBy(cardSource, 'id')[id]) || {id: id, label: '' + id, columnSpan:1}
if (item.columnSpan && item.columnSpan > columns)
Expand Down

0 comments on commit f770d13

Please sign in to comment.