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

Do not allow dropping text on the columns #3353

Merged
merged 4 commits into from
Oct 2, 2023
Merged

Conversation

amanmahajan7
Copy link
Contributor

Fixes #3349

@amanmahajan7 amanmahajan7 self-assigned this Oct 2, 2023
@@ -201,7 +206,7 @@ export default function HeaderCell<R, SR>({
}

function onDragStart(event: React.DragEvent<HTMLDivElement>) {
event.dataTransfer.setData('text/plain', column.key);
event.dataTransfer.setData(dragDropKey, column.key);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amanmahajan7 amanmahajan7 marked this pull request as ready for review October 2, 2023 14:58
@amanmahajan7 amanmahajan7 requested a review from nstepien as a code owner October 2, 2023 14:58
@@ -51,6 +53,8 @@ const cellOver = css`

const cellOverClassname = `rdg-cell-drag-over ${cellOver}`;

const dragDropKey = 'column-key';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably make this unique for each grid instance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using useId to generate uniqueKey for each grid

@codecov
Copy link

codecov bot commented Oct 2, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@cf88802). Click here to learn what that means.
The diff coverage is 88.23%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3353   +/-   ##
=======================================
  Coverage        ?   82.98%           
=======================================
  Files           ?       47           
  Lines           ?     5071           
  Branches        ?      789           
=======================================
  Hits            ?     4208           
  Misses          ?      863           
  Partials        ?        0           
Files Coverage Δ
src/HeaderRow.tsx 98.11% <100.00%> (ø)
src/HeaderCell.tsx 85.38% <84.61%> (ø)

Comment on lines +226 to +227
if (event.dataTransfer.types.includes(dragDropKey)) {
const sourceKey = event.dataTransfer.getData(dragDropKey);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can probably add an undefined check instead but need to ignore the types
image

@amanmahajan7 amanmahajan7 merged commit 5480250 into main Oct 2, 2023
3 checks passed
@amanmahajan7 amanmahajan7 deleted the am-fix-draggable branch October 2, 2023 16:13
adityatoshniwal pushed a commit to pgadmin-org/react-data-grid that referenced this pull request Jul 31, 2024
* Do not allow dropping text on the columns

* Fix test

* Use `useId` to generate unique key
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.

Columns reordering: demo crash
2 participants