Skip to content

Add draggedOver to state.eventsΒ #28

Closed
@ackvf

Description

/edit Title changed from

Why is dragged item also hovered when dragging over another item?

This is not a bug per se, but still an unexpected and weird behaviour.
I am dragging an item from its former location to another location, my cursor is above another Container, but the original dragged item still remains hovered even though that doesn't really make sense.
image

I have discovered this weird behaviour while trying to work around the limitation in #26.
I desperately need to tell which element am I currently dragging over. I used this custom proxy hack to achieve that, maybe it's wrong and I am getting stale value there?

const BoxListItem: UserComponent<BoxListItemProps> = props => {
  const { id, connectors: { connect, drag } } = useNode();
  const { actions: { setCustom }, hovered } = useEditor(state => console.debug('hovered', state.events.hovered) || ({ hovered: state.nodes[state.events.hovered].data.type }) )

  setCustom(id, custom => custom.hovered = hovered)
 
  // return JSX
BoxListItem.craft = {
  rules: {
    canDrag: node => console.debug('node.data.custom.hovered === ', node.data.custom.hovered === BoxList, node.data.custom.hovered) || node.data.custom.hovered === BoxList
  }
}
// this is where the state keeps printing
export const PropertiesPanel = () => {
  const {  PropsPanel, name } = useEditor(state => {
    if (!state.events.selected) return;
    console.debug('state', state.events, state)
    // return collector

Even though I will work on the canDrop rule as mentioned in #26 to implement the functionality, I believe that the editor state should better reflect what events are happening.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions