Esri / calcite-design-system

A monorepo containing the packages for Esri's Calcite Design System
https://developers.arcgis.com/calcite-design-system/
Other
269 stars 75 forks source link

Popover should only get closed when clicking outside if the click was not initiated inside #9506

Open hcampos-professional opened 4 weeks ago

hcampos-professional commented 4 weeks ago

Check existing issues

Description

At the time of writing, the <calcite-popover auto-close> is closed when the user clicks outside of it, even if the pointer/mouse down was done inside of the popover. That makes it very easy to accidentally the popover when selecting text, in it, for example: a user presses the mouse and starts dragging to select the text, but releases the pointer outside of the popover, causing it to be closed.

This is fairly easy to work around by tracking pointerdown and mousedown and then using onCalcitePopoverBeforeClose to prevent the dialog being closed if the down events happened outside of the popover. However, it would be nicer if it was supported directly by Calcite.

Acceptance Criteria

The popover should only be automatically closed if the "full click" gesture happened outside of it.

Relevant Info

No response

Which Component

### Example Use Case This came up in the context of the SceneViewer application which sometimes uses a popover with an input inside for renaming certain things. If the user tries to select the text in the input but releases the mouse outside, the popover gets closed. ### Priority impact impact - p3 - not time sensitive ### Calcite package - [X] @esri/calcite-components - [ ] @esri/calcite-components-angular - [ ] @esri/calcite-components-react - [ ] @esri/calcite-design-tokens - [ ] @esri/eslint-plugin-calcite-components ### Esri team ArcGIS Scene Viewer
driskull commented 3 weeks ago

@jcfranco I think this is a regression from https://github.com/Esri/calcite-design-system/pull/8943

We switched from pointerdown to click.

This works fine in 2.6.0 https://codepen.io/driskull/pen/QWRMjPE?editors=100

Should we move back to pointerdown?

jcfranco commented 3 weeks ago

We also need to track where the release happens since the previous behavior was prone to closing early (e.g., the popover shouldn't close if a click starts outside and ends within the popover or vice versa).

This would also apply to tooltip.