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: restore focus on the canvas when properties panel loses focus #1093

Closed
wants to merge 2 commits into from

Conversation

jarekdanielak
Copy link
Contributor

Proposed Changes

Related to https://github.com/bpmn-io/internal-docs/issues/1081
Related to camunda/camunda-modeler#4620

Make use of the new diagram-js@15 Canvas#restoreFocus API to focus back on the canvas when properties panel loses focus.

In addresses a case explain in this comment, when user briefly interacts with properties panel without focusing any input. In that case, we want the focus to stay on the modeling canvas.

Checklist

To ensure you provided everything we need to look at your PR:

  • Brief textual description of the changes present
  • Visual demo attached
  • Steps to try out present, i.e. using the @bpmn-io/sr tool
  • Related issue linked via Closes {LINK_TO_ISSUE} or Related to {LINK_TO_ISSUE}

@@ -158,6 +163,11 @@ export default class BpmnPropertiesPanelRenderer {
return event.providers;
}

_restoreCanvasFocus() {
const canvas = this._injector.get('canvas');
canvas && canvas.restoreFocus && canvas.restoreFocus();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
canvas && canvas.restoreFocus && canvas.restoreFocus();
// support diagram-js@15+
if (canvas.restoreFocus) {
canvas.restoreFocus();
}

Copy link
Member

@nikku nikku Nov 20, 2024

Choose a reason for hiding this comment

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

canvas will always be there (or otherwise inject.get('name') would have blown up already.

If you want canvas to be optional, do injector.get('canvas', false).

Copy link
Member

Choose a reason for hiding this comment

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

For a moment I thought we could simply hook into our focus* events, until I realized we don't have those...

@jarekdanielak jarekdanielak requested a review from nikku November 20, 2024 09:48
Copy link
Member

@nikku nikku left a comment

Choose a reason for hiding this comment

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

Not sure what I'm doing wrong, but this does not work as it should:

capture o5VpVx_optimized

Did you try it (npm start) and see a different behavior?

@bpmn-io-tasks bpmn-io-tasks bot added in progress Currently worked on and removed needs review Review pending labels Nov 20, 2024
Copy link
Member

@nikku nikku left a comment

Choose a reason for hiding this comment

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

Ok, so my organized thoughts on this PR, looking at how it is built:

It feels odd that we don't have proper eventBus events to hook into to integrate the focus change. Like a house we want to build "foundations" as we add new features (or balconies), and I'd assume that a propertiesPanel.focus.changed event (similar to the new canvas.focus.changed event) allows me to hook in the behavior.

I sketched that via this branch, which also contains fixes for the broken focus change within the panel that I reported.

UX wise, I suggest you to do always do some exploratory testing. It would be odd if we introduce silly bugs because we did not verify that the thing we fix works in the large scheme of things.

@jarekdanielak
Copy link
Contributor Author

Closing this pull request as we want to go with a follow-up by Nico - #1094

@bpmn-io-tasks bpmn-io-tasks bot removed the in progress Currently worked on label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants