当我拖动一个元素时,react-sortable-hoc 列表消失
react-sortable-hoc List disappears when I drag an element
JSFiddle:https://jsfiddle.net/40vpaLj5/
我用谷歌搜索了一些问题,我发现唯一消失的相关问题是当人们在模态上使用它并且他们谈论设置 z-index 来修复它时。无论如何我试过了还是没有。我该如何解决这个问题?
import React from 'react';
import PlaylistPages from './PlaylistPages';
class PlaylistSortableComponent extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
test: [
'1','2', '3', '4'
]
}
}
render() {
return (
<PlaylistPages pages={this.state.test} style={{zIndex: 999999}} />
);
}
}
const PlaylistPages = SortableContainer(({pages}) => {
return (
<div>
{
pages.map((page, index) =>
<PlaylistPage key={index} page={page} style={{zIndex: 99999999}} />
)}
</div>
);
});
const PlaylistPage = SortableElement(({page}) => {
return (
<div style={{zIndex: 99999999}} >{page}</div>
);
});
每个 sortableElement
都应该有自己的 index
道具:
<PlaylistPage key={index} index={index} page={page} style={{zIndex: 99999999}} />
这是对您的 jsfiddle 的更新:
https://jsfiddle.net/40vpaLj5/1/
我遇到了同样的问题,Dekel 是对的。在我的例子中,z-index 修复了错误:
<SortableList
axis="y"
helperClass="sortable-list-tab"
lockAxis="y"
distance={0}
onSortEnd={onSortEnd}
>
<ul>
{toolItems.map((value, index) => (
<SortableItem key={`item-${index}`} index={index}>
<li className="sortable-list-tab" >
<Button type="dashed">{`${value.label} (${index + 1})`}</Button>
</li>
</SortableItem>
))}
</ul>
</SortableList>
而 sortable-list-tab class 看起来像:
.sortable-list-tab {
cursor: default;
visibility: visible;
z-index: 99999999;
list-style-type: none;
padding: .3em;
}
JSFiddle:https://jsfiddle.net/40vpaLj5/
我用谷歌搜索了一些问题,我发现唯一消失的相关问题是当人们在模态上使用它并且他们谈论设置 z-index 来修复它时。无论如何我试过了还是没有。我该如何解决这个问题?
import React from 'react';
import PlaylistPages from './PlaylistPages';
class PlaylistSortableComponent extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
test: [
'1','2', '3', '4'
]
}
}
render() {
return (
<PlaylistPages pages={this.state.test} style={{zIndex: 999999}} />
);
}
}
const PlaylistPages = SortableContainer(({pages}) => {
return (
<div>
{
pages.map((page, index) =>
<PlaylistPage key={index} page={page} style={{zIndex: 99999999}} />
)}
</div>
);
});
const PlaylistPage = SortableElement(({page}) => {
return (
<div style={{zIndex: 99999999}} >{page}</div>
);
});
每个 sortableElement
都应该有自己的 index
道具:
<PlaylistPage key={index} index={index} page={page} style={{zIndex: 99999999}} />
这是对您的 jsfiddle 的更新:
https://jsfiddle.net/40vpaLj5/1/
我遇到了同样的问题,Dekel 是对的。在我的例子中,z-index 修复了错误:
<SortableList
axis="y"
helperClass="sortable-list-tab"
lockAxis="y"
distance={0}
onSortEnd={onSortEnd}
>
<ul>
{toolItems.map((value, index) => (
<SortableItem key={`item-${index}`} index={index}>
<li className="sortable-list-tab" >
<Button type="dashed">{`${value.label} (${index + 1})`}</Button>
</li>
</SortableItem>
))}
</ul>
</SortableList>
而 sortable-list-tab class 看起来像:
.sortable-list-tab {
cursor: default;
visibility: visible;
z-index: 99999999;
list-style-type: none;
padding: .3em;
}