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

fix(ts): make onChange argument optional #584

Closed

Conversation

lukasnys
Copy link

In the addon/src/modifiers/sortable-group.ts file, the onChange argument is marked as required. However, looking at the implementation, it looks like it should be optional instead.

Copy link

netlify bot commented Sep 25, 2024

Deploy Preview for ember-sortable canceled.

Name Link
🔨 Latest commit 1e6dd01
🔍 Latest deploy log https://app.netlify.com/sites/ember-sortable/deploys/66f3c897dc6d1e000852eb4d

@NullVoxPopuli
Copy link
Contributor

What's the usecase for not having @onChange?

@mkszepp
Copy link
Contributor

mkszepp commented Sep 25, 2024

i think the only usecase for optional with latest is when there is disabled=true or? because without onChanges the data will never be changes

Looking into code docs there is declared as optional, but maybe its historcally, when there was 2-way binding... is it possible?

/**
* Modifier to apply a11y support to a group container for the Sortable component
*
* @param {String} [a11yItemName] A name for each model, used for creating more meaningful a11y announcements.
* @param {Object} [a11yAnnouncementConfig] A map of action to function to build meaningful a11y announcements.
* @param {String} [itemVisualClass] A class for styling visual indicators on the yielded `sortable-item`.
* @param {Object} [handleVisualClass] An object for styling visual indicators on the yielded `sortable-handle` on different `move`.
* @param {Function} [onChange] An optional callback for when position rearrangements are confirmed.
*
* @module drag-drop/draggable-group
* @example
* <ol {{sortable-group onChange=this.update a11yAnnouncementConfig=this.myA11yConfig}}>
* {{#each model.items as |item|}}
* <li {{sortable-item model=item}}>
* {{item.name}}
* <span class="handle" {{sortable-handle}}>&varr;</span>
* </li>
* {{/each}}
* </ol>
*/

I think in real cases you need always to pass a onChange

@lukasnys
Copy link
Author

You both make good points. I saw a usage in our code base where we don't pass a onChange so I figured it was a valid use case. Turns out this makes for some really weird and un-user-friendly behaviour so I'm getting rid of it.

Closing this PR as it indeed doesn't make sense!

@lukasnys lukasnys closed this Sep 26, 2024
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.

3 participants