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

feat(create): allow create with keyboard #733

Closed
wants to merge 1 commit into from

Conversation

smbea
Copy link
Contributor

@smbea smbea commented Jan 17, 2023

@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Jan 17, 2023
@smbea smbea requested review from barmac and nikku January 17, 2023 09:31
@smbea
Copy link
Contributor Author

smbea commented Jan 17, 2023

@barmac @nikku could one of you have a look? Would love to get this in and released so I can move on with bpmn-io/bpmn-js#1802

@@ -307,6 +308,10 @@ export default function Create(
});
});

if (event instanceof KeyboardEvent) {
Copy link
Member

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 invoke Create.start with a mouse event (that you got from wherever).

While I like your solution we did it differently in the past, cf.

this._create.start(this._mouse.getLastMoveEvent(), elements, {
.

Did you consider the alternative?

Copy link
Contributor Author

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.

Copy link
Member

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 a MouseEvent over null into create.start(...)? If there is none then I'd advocate to make it possible to call create.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.

Copy link
Member

Choose a reason for hiding this comment

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

But I can also see how it may look random in the middle of create.

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.

Copy link
Member

@nikku nikku Jan 17, 2023

Choose a reason for hiding this comment

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

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.

If this does not involve much work I'd favor the local solution, I think.

Copy link
Contributor Author

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.

@smbea smbea closed this Jan 17, 2023
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Jan 17, 2023
@nikku nikku deleted the allow-dragstart-from-keyboard branch January 17, 2023 17:16
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.

2 participants