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

feat(block-group, list): Add event for when a move is halted due to canPut or canPull returning false #11567

Merged
merged 15 commits into from
Apr 2, 2025

Conversation

driskull
Copy link
Member

@driskull driskull commented Feb 15, 2025

Related Issue: #11447

Summary

  • Add event for when a user uses the sort dropdown and canPull or canPut returns false
    • Call canPull and canPut when moving items via the "Move to" menu provided under the drag handle
    • If an item cannot be pulled or put, an event is emitted.
    • Users should handle these events to show a notification of their choice
  • Adds tests

@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Feb 15, 2025
@driskull driskull added the skip visual snapshots Pull requests that do not need visual regression testing. label Feb 18, 2025
@driskull driskull changed the title fix(block-group, list): call canPull and canPut when moving items via menu. feat(block-group, list): Add events for when a user uses the sort menu and canPull or canPut returns false Feb 19, 2025
@driskull driskull changed the title feat(block-group, list): Add events for when a user uses the sort menu and canPull or canPut returns false feat(block-group, list): Add events for when a user uses the sort dropdown and canPull or canPut returns false Feb 19, 2025
@driskull driskull marked this pull request as ready for review February 19, 2025 22:57
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions.

@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Feb 28, 2025
# Conflicts:
#	packages/calcite-components/src/components/list/list.tsx
@driskull
Copy link
Member Author

@jcfranco @macandcheese this is still awaiting review.

@github-actions github-actions bot added the enhancement Issues tied to a new feature or request. label Mar 28, 2025
@github-actions github-actions bot removed the Stale Issues or pull requests that have not had recent activity. label Mar 30, 2025

if (!fromEl) {
return;
}

if (
Copy link
Member

Choose a reason for hiding this comment

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

Since this is shared, let’s create a utility for both list and block-list to use, and do the same for their tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we do this as part of a new refactor issue?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, but let’s make it a priority to unify these paths as soon as possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

created #11849

Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

↕️🤏✨

@jcfranco
Copy link
Member

jcfranco commented Apr 1, 2025

PR-title/changelog-wise, would developers know when canPull/canPut returns false? Maybe rephrasing to emphasize what these events will enable would be helpful.

@driskull driskull changed the title feat(block-group, list): Add events for when a user uses the sort dropdown and canPull or canPut returns false feat(block-group, list): Add events for when a move is prevented with canPut or canPull Apr 1, 2025
@driskull
Copy link
Member Author

driskull commented Apr 1, 2025

@jcfranco how about feat(block-group, list): Add events for when a move is prevented with canPut or canPull #11567

Also, are the event names acceptable? I wasn't sure if Fail was the right term or if we wanted something different. Other potential terms: rejected, prevented, stopped, disabled

Spawns from this option: https://github.com/SortableJS/Sortable?tab=readme-ov-file#group-option

@jcfranco
Copy link
Member

jcfranco commented Apr 2, 2025

how about feat(block-group, list): Add events for when a move is prevented with canPut or canPull #11567

🚢 it!

Also, are the event names acceptable?

Good question. Fail makes it sound like canPut or canPull threw an error.

This got me thinking, if a developer is handling failed moves, will they typically need to listen for both events? If so, maybe they can share the same event regardless of canPut or canPull (with this info as part of the event payload, if needed). Something like calcite<Component>MoveHalt?

@driskull
Copy link
Member Author

driskull commented Apr 2, 2025

Something like calciteMoveHalt?

Yeah we could do that. Should I proceed?

@jcfranco
Copy link
Member

jcfranco commented Apr 2, 2025

SGTM!

@driskull driskull changed the title feat(block-group, list): Add events for when a move is prevented with canPut or canPull feat(block-group, list): Add event for when a move is prevented with canPut or canPull Apr 2, 2025
@driskull driskull changed the title feat(block-group, list): Add event for when a move is prevented with canPut or canPull feat(block-group, list): Add event for when a move is halted due to canPut or canPull returning falsy Apr 2, 2025
@driskull driskull changed the title feat(block-group, list): Add event for when a move is halted due to canPut or canPull returning falsy feat(block-group, list): Add event for when a move is halted due to canPut or canPull returning false Apr 2, 2025
@driskull driskull merged commit 98bf85d into dev Apr 2, 2025
18 checks passed
@driskull driskull deleted the dris0000/canPull-canPut-keyboard-fix branch April 2, 2025 18:59
@github-actions github-actions bot added this to the 2025-04-29 - Apr Milestone milestone Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug. enhancement Issues tied to a new feature or request. skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants