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

fix(tooltip): clean up focus handling #273

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Conversation

smbea
Copy link
Contributor

@smbea smbea commented Aug 2, 2023

@bpmn-io-tasks bpmn-io-tasks bot added the in progress Currently worked on label Aug 2, 2023
@smbea smbea marked this pull request as ready for review August 2, 2023 11:51
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Aug 2, 2023
@smbea smbea requested review from marstamm and barmac August 2, 2023 11:52
@pinussilvestrus
Copy link
Contributor

Do you plan to have this fix in the current release already? I'm asking because I already released the popup editor via a minor version, so bumping the properties panel would mean we introduce this everywhere.

Not a problem, just wanted to make sure we are aware of this 👍

@smbea
Copy link
Contributor Author

smbea commented Aug 2, 2023

Do you plan to have this fix in the current release already? I'm asking because I already released the popup editor via a minor version, so bumping the properties panel would mean we introduce this everywhere.

Not a problem, just wanted to make sure we are aware of this 👍

Would this change anything, since it hans't been released with form-js? I don't think this is blocking, so we can postpone releasing

@barmac
Copy link
Member

barmac commented Aug 3, 2023

Thanks for a quick fix. How would I test this? Could you share what the root cause of the problem is?

@smbea
Copy link
Contributor Author

smbea commented Aug 3, 2023

Thanks for a quick fix. How would I test this?

You can test it by liking this branch in bpmn-js-properties-panel. I recommend trying it out with the timer props because the tooltip has more content.

Could you share what the root cause of the problem is?

Like I mentioned above, we added a preventDefault on mouseDown to the container div to ensure group headers tooltips wouldn't stay always visible after clicking on them to open. This made it so that when trying to select the content, the default selection behaviour didn't happen. So I stopped propagation of the events within the tooltip content div. Happy to explain further via call if my explanation was confusing

@barmac
Copy link
Member

barmac commented Aug 3, 2023

So if I get it correctly, we want to keep the interaction within tooltip. Is there any need for prevent default in that case?

@barmac
Copy link
Member

barmac commented Aug 3, 2023

Also, it would be cool to have automatic tests for both renderPortal and direct render case. Thus, we can easily verify the correct behavior, and more important catch it when it breaks again.

@smbea
Copy link
Contributor Author

smbea commented Aug 3, 2023

So if I get it correctly, we want to keep the interaction within tooltip. Is there any need for prevent default in that case?

The prevent default prevents the trigger element (group header) to become focused via mouse, thus keeping the tooltip open. We only want that to happen via keyboard navigation.

Also, it would be cool to have automatic tests for both renderPortal and direct render case. Thus, we can easily verify the correct behavior, and more important catch it when it breaks again.

I can work on adding test cases for createPortal

@smbea
Copy link
Contributor Author

smbea commented Aug 4, 2023

There is actually a test for rendering via portal

I haven't been able to add a test case that reproduces the content selectable or the focus issue I mentioned was fixed with prevent default.

@smbea smbea added in progress Currently worked on and removed needs review Review pending labels Aug 7, 2023
@smbea smbea changed the title fix(tooltip): content selectable fix(tooltip): clean up focus handling Aug 8, 2023
@smbea
Copy link
Contributor Author

smbea commented Aug 8, 2023

When trying to fix #272 and camunda/camunda-modeler#3756, I ended up breaking one while fixing the other. This is because preventing default actions in some places (like focus on mouseDown) also ends up preventing wanted actions (like selecting context).

In order to not end up with super confusing code trying to gracefully handle these events, I decided to clean up how we open/persist tooltips based on focus - which is what causes all the issues.

I also added some test cases which should help enforce this, but it's hard to test these things for every case so feel free to give it a good user test.

@barmac barmac removed their request for review August 11, 2023 15:08
Copy link
Contributor

@marstamm marstamm left a comment

Choose a reason for hiding this comment

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

I can confirm that this fixes the selection issue in a browser environment. Good job cleaning up the opening handling.

As expected, in the Camunda Modeler, selection is still blocked for the whole modeler container

Recording 2023-08-14 at 10 48 37

@fake-join fake-join bot merged commit 8a411f9 into main Aug 14, 2023
12 checks passed
@fake-join fake-join bot deleted the fix-content-selectable branch August 14, 2023 08:55
@bpmn-io-tasks bpmn-io-tasks bot removed the in progress Currently worked on label Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Tooltip content isn't selectable
4 participants