-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Implemented Gallery Drag and Drop Reordering #7946
Implemented Gallery Drag and Drop Reordering #7946
Conversation
We can extract It will be a good addon to current available which are being moved to separate package It can be used internally and also by block developers Something similar a hoc component using react-sortable-hoc https://github.com/lucprincen/gutenberg-sortable |
Yeah having it as a generic independent component would be ideal. Right now it's being specific to this block behavior though. I think after its completed it can be extracted. |
Hey everyone I was wondering whether the reordering behaviour should work with a hold press delay to start dragging, or a handle from where you can drag instantaneously. What do you think? |
Why does it need to have a trigger? Can't it just work on mouse drag? If it has to have one I guess hold press but I'd love it to 'just work'. |
Yeah, I would prefer instant drag as well, unless there is some technical issue that prevents it. |
gotcha! i'll aim towards that behaviour then! |
6b893d1
to
19a7dc8
Compare
Right now im dealing with the Image Caption Focus resetting after 1 key stroke. I have just now noticed it has been caused by the HOC around the GalleryImage components. The SortableContainer HOC seems to be always rerendering the whole thing even after 1 click or key stroke, which causes the focus to be lost |
91c3c91
to
f1b4e55
Compare
I'm getting an exception when I:
|
package.json
Outdated
@@ -55,6 +55,7 @@ | |||
"re-resizable": "4.7.1", | |||
"react": "16.4.1", | |||
"react-dom": "16.4.1", | |||
"react-sortable-hoc": "0.8.3", |
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.
How many bytes does this add to our bundle size?
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.
Around 40 KB
Thanks for spotting that. It should be addressed now. |
This |
What are the trade-offs between using it or rolling our own? |
There are some code formatting/style issues that should be fixed. Are you running a linter? |
core-blocks/gallery/sortable.js
Outdated
const SortableItem = SortableElement( ( { children } ) => children ); | ||
|
||
class Sortable extends Component { | ||
//constructor |
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.
Why comment here?
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.
Also, we could get rid of the constructor all together using by using class properties.
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.
You are right let me fix that
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.
we don't have support for class properties enabled though, and other blocks/components seem to be relying on binding inside the constructor as well. Should we enable it?
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.
We're reluctant to use new language features until they've reached stage 4. Class fields are still at stage 3.
Yes I am using eslint on vscode. You mean the function comments right? Thanks for noticing that. I'll check and solve it |
201b54e
to
ba90922
Compare
@ehg Rolling our own one or a fork would let us modify the component that is being rendered while dragging and also address the performance issues directly; however, it would take more time. |
Hey, so I addressed the sizing issue when reordering. It now looks nice like this: I was thinking I would need to set a class on the rearranging elements until I realized the dynamic size of the gallery items is not caused by a different class, but by their However, this behaviour has been achieved by modifying the dependency library I created a PR there (clauderic/react-sortable-hoc#422), but he doesn't really look that active right now. 👎 |
Hey, just wanted to note that if it crossed your mind to get rid of |
@nosolosw Can you just provide us with full example for how to use the |
@muhammedmagdi the PR I've mentioned also updates the docs, see That PR is now approved and it's going to be merged into master next week, after the 3.7 Gutenberg release. From that point on, it'll be available for anyone to use. |
@nosolosw |
* Created new Sortable HOC for wrapping the Gallery Images * Added react-sortable-hoc dependency * Right now you have to hold down to reorder
Altered the Sortable component so it now handles custom first and last nodes.
Addresses the floating square when dragging
Got rid of closure higher order component in favor of readability
3ab09fb
to
5fef65b
Compare
The Gallery Item Image did not have proper styling because of the way the dragged element is created (outside its <ul>) This adds the necessary css to address this.
5fef65b
to
e1357bf
Compare
@mapk and @youknowriad - what's the plan regarding this feature for Phase 2? |
@gziolo It just needs dev :) |
@gziolo @youknowriad I had this on my radar to work on after my the doc generator task. We may want to close this PR and reference the master issue #743 everywhere (it contains other references). I'll just do that. If we end up using this approach, we can always reopen. |
Awesome, thanks @nosolosw for making it clear. Indeed, we can always reopen as we get back to this issue. Let's keep the number of open PRs in a healthy state :) |
Description
Addresses Issue #743
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist:
My code follows the WordPress code style.
My code has proper inline documentation.
My code is tested.
My code follows the accessibility standards.
KNOWN ISSUES: