Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No dnd backend provided #1677

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gaut-b
Copy link

@gaut-b gaut-b commented Mar 7, 2021

This PR follows #1536 which allows to manage cases where no DND backend is provided.

The original PR conditionally called the hooks "useDrag" and "useColumnDrop" in the TableHeadCell component, but it seems that these changes have been overwritten in commit e75d2fe. Therefore, a bug appears in the TableHeadCell component if no DnDbackend is provided (which is quite a neat feature).

So I propose a quickfix in which I created a new component named TableHeadCellNoDnd which is called if dragNDrop is not explicitly enabled.

I added a working example of a table to which is passed "components={{DragDropBackend: null}}".

@wdh2100
Copy link
Collaborator

wdh2100 commented Mar 9, 2021

@gaut-b

That's a good opinion.
However, if there is one thing that takes, there are a lot of duplicate codes.
How about making it with Higher-order Component?

@wdh2100
Copy link
Collaborator

wdh2100 commented Mar 9, 2021

I will consider whether it is possible to change it in the current structure (TableHeadCell - TableHeadCellNoDnD)

@gaut-b
Copy link
Author

gaut-b commented Mar 9, 2021

Thanks for the review. This PR was a quickfix and indeed not very "DRY". HOC is indeed a good idea and I will try to get back to you in the next few days with a proposal.

However, the cleanest way in my opinion would be to put back the conditional calls on the hooks following the value of isDraggingEnabled.I don't think there are cases where a backend is provided or not dynamically, so a conditional call on hooks should not be a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants