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

Allow using a Function as the cancel option instead of a Selector. #2324

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kghandi
Copy link

@kghandi kghandi commented Jan 8, 2025

This is particularly useful when using Sortable on nested lists.
I had a similar issue to that listed in issue #1996. Allowing cancel option to be a function allows me to override the default cancel implementation using a selector with something like:

$('.container', context).sortable({
items: '>.widget',
cancel: function (event) {
return $(event.target).closest('.widget').is('.locked');
}
});

…is is particularly useful when using Sortable on nested lists.
Copy link

linux-foundation-easycla bot commented Jan 8, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. This change makes sense to me, although before formally accepting I'd like @fnagel to also voice his opinion for possible wider context.

If Felix agrees this makes sense, there are still a number of changes we need before accepting this PR:

  1. Make sure you follow our style guide: https://contribute.jquery.org/style-guide/js/. Currently, indentation is wrong, it uses spaces instead of tabs, spaces are missing inside of parens, etc.
  2. Connected to the above - make sure our tests & linters succeed on the code before asking for another review. In this case, ESLint fails, for example. Run npm install && npm run build && npm run lint && npm test locally and see if everything works.
  3. This change needs tests in all affected modules: draggable, sortable, etc. - perhaps whatever depends on $.ui.mouse.
  4. This needs API updates so we'll need a PR to https://github.com/jquery/api.jqueryui.com/ as well before merging any new API.

@fnagel
Copy link
Member

fnagel commented Jan 15, 2025

Sounds reasonable to me and the changes are not that big, so I'm fine with integrating this when all requirements are met.

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

Successfully merging this pull request may close these issues.

3 participants