-
-
Notifications
You must be signed in to change notification settings - Fork 464
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
Issue#271 #956
Issue#271 #956
Conversation
hi, is this project already finished? If you find this pull request unnecessary, or if further modifications are required, please feel free to reject or suggest necessary revisions. |
src/html5sortable.ts
Outdated
setDragImage(e, dragItem, options.customDragImage) | ||
let dragImage: Function | NodeList = null | ||
if (typeof options.customDragImage === 'string') { | ||
dragImage = document.querySelectorAll(options.customDragImage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @yuki-katayama do you use querySelector
All
on purpose? Wouldn't it be better to use querySelector
in case multiple items with e.g. a class exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lukasoppermann. Thank you for your review.
I think so too about using querySelector
instead. At first, I chose querySelectorAll
considering the future prospects of the implementation, but I thought it would be a good idea to implement it again when it becomes necessary.
Also, when using querySelector
, the code now defaults to the defaultDragImage
function instead of throwing an error if the element is not found.
Therefore, we changed the error handling from throwing an exception
to logging the error using console.error
. Please review the changes and let us know if further adjustments are needed.
Thank you for your feedback!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test results.
PASS __tests__/setDragImage.test.ts
PASS __tests__/options.test.ts
PASS __tests__/sortableMethodsTests/_removeItemData.test.ts
PASS __tests__/serialize.test.ts (5.065s)
PASS __tests__/api.test.ts (5.2s)
PASS __tests__/isConnected.test.ts (5.241s)
PASS __tests__/events/events.test.ts (5.536s)
PASS __tests__/elementHeight.test.ts
PASS __tests__/sortableMethodsTests/_removeItemEvents.test.ts
PASS __tests__/filter.test.ts
PASS __tests__/elementWidth.test.ts
PASS __tests__/events/hoverClass.test.ts
PASS __tests__/store/storeConfig.test.ts
PASS __tests__/getHandles.test.ts
PASS __tests__/makePlaceholder.test.ts
PASS __tests__/insertAfter.test.ts
PASS __tests__/throttle.test.ts
PASS __tests__/store/storeData.test.ts
PASS __tests__/store/storePlaceholder.test.ts
PASS __tests__/index.test.ts
PASS __tests__/insertBefore.test.ts
PASS __tests__/offset.test.ts
PASS __tests__/isInDom.test.ts
PASS __tests__/debounce.test.ts
PASS __tests__/store/store.test.ts
-------------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-------------------------|----------|----------|----------|----------|-------------------|
All files | 86.1 | 74.62 | 89.9 | 86.19 | |
attribute.ts | 100 | 100 | 100 | 100 | |
data.ts | 100 | 100 | 100 | 100 | |
debounce.ts | 100 | 100 | 100 | 100 | |
defaultConfiguration.ts | 100 | 100 | 100 | 100 | |
elementHeight.ts | 100 | 100 | 100 | 100 | |
elementWidth.ts | 100 | 100 | 100 | 100 | |
eventListener.ts | 100 | 100 | 100 | 100 | |
filter.ts | 100 | 100 | 100 | 100 | |
getEventTarget.ts | 100 | 66.67 | 100 | 100 | 6 |
getHandles.ts | 100 | 70 | 100 | 100 | 20,25 |
getIndex.ts | 100 | 100 | 100 | 100 | |
hoverClass.ts | 100 | 100 | 100 | 100 | |
html5sortable.ts | 75.55 | 49.03 | 76.74 | 76.19 |... 24,645,646,660 |
insertHtmlElements.ts | 100 | 100 | 100 | 100 | |
isConnected.ts | 100 | 100 | 100 | 100 | |
isInDom.ts | 100 | 100 | 100 | 100 | |
makePlaceholder.ts | 100 | 100 | 100 | 100 | |
offset.ts | 100 | 100 | 100 | 100 | |
serialize.ts | 100 | 100 | 100 | 100 | |
setDragImage.ts | 100 | 100 | 100 | 100 | |
store.ts | 100 | 100 | 100 | 100 | |
throttle.ts | 100 | 100 | 100 | 100 | |
-------------------------|----------|----------|----------|----------|-------------------|
Test Suites: 25 passed, 25 total
Tests: 7 skipped, 123 passed, 130 total
Snapshots: 0 total
Time: 10.198s
Ran all test suites.
$ standard 'src/*.ts' '__tests__/*.ts' | snazzy
Sorry for the delay. Looks good @yuki-katayama just one comment. |
@lukasoppermann
Description
This issue aims to address two main changes to improve the functionality of the HTML5Sortable library:
Enhancement of Custom Drag Image Selection: Extend the
sortable
function to allowcustomDragImage
option to accept a string selector, in addition to the existing function type. This enhancement will make it more flexible for users to specify custom drag images directly via CSS selectors.Testing for Custom Drag Image: Implement tests to ensure that custom drag images defined by CSS selectors are correctly applied, and to handle cases where the selector does not match any elements, ensuring the code robustness.
Tasks
sortable
function to handle string selectors forcustomDragImage
.setDragImage
function to properly handle NodeList objects derived from string selectors.Related Issues
issue#271
Implementation Video
using code
Test results