-
Notifications
You must be signed in to change notification settings - Fork 418
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(create): allow create with keyboard #733
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There are two options to go about this:
Make
Create.start
work out-of-the-box, implicitly using the mouse utility or explicitly invokeCreate.start
with a mouse event (that you got from wherever).While I like your solution we did it differently in the past, cf.
diagram-js/lib/features/copy-paste/CopyPaste.js
Line 242 in 9df8848
Did you consider the alternative?
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.
I didn't come across this in my deep dive unfortunately 😅 We can do this approach too and I guess it's more contained.
The approach I did adds it to the core and prevents us from having to think about it again. Seeing as it is something useful in general and not just this one case, it might make sense to go this way. As far as I could tell (me and the test suite 🤣), it didn't "ruin" anything else. But I can also see how it may look random in the middle of
create
.I don't have a super strong opinion: if we would rather keep this on a need-to-use basis locally, i'm also happy would 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.
Let us consider it like this:
What value do I get from passing in a
KeyEvent
over aMouseEvent
overnull
intocreate.start(...)
? If there is none then I'd advocate to make it possible to callcreate.start
without an event, defaulting to the last mouse move event, if provided.If there is one, let's ensure that we don't break 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 could make the dependency to
mouse
an optional one (injector.get('mouse', false)
) and clearly document that the last good known mouse position is chosen, if no event is provided.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.
If this does not involve much work I'd favor the local solution, I think.
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.
Works for me. I will close this PR then and handle it locally.