iTwin / iTwinUI-react

A react component library for iTwinUI.
https://github.com/iTwin/iTwinUI
Other
83 stars 23 forks source link

Input: stop event propagation #899

Closed FelixGirard closed 1 year ago

FelixGirard commented 1 year ago

Describe the bug (actual behavior)

When entering text in an Input, it may activate a tool in the active viewer (if one is open). For example, if I search 'e' in the Tree View, the rotation tool activate:

MicrosoftTeams-image (21)

Expected behavior

By default, I would expect an Input to stop the propagation of the event.

Reproduction

Link to a minimal repro:

Steps to reproduce
  1. Create a widget with an input.
  2. Type a key that activate a tool ('e' for example)

Additional information

I know I can provide functions that stop the event propagation. I think it could cause confusion for anyone working in widgets, and that we probably want this more often than not.

mayank99 commented 1 year ago

Hey @FelixGirard, I'm not sure I understand why you would expect our Input to behave differently from the native browser input. If you want this more often than not, then you could create a wrapper over our input that calls stopPropagation and reuse it everywhere.

FelixGirard commented 1 year ago

I would expect it to behave differently because I guess most of the use of the component is with an open iTwin Viewer. I wish there was at least an option for that in the component, to not force each team working in widgets to create their own.

mayank99 commented 1 year ago

I think it might make more sense for iTwin Viewer shortcuts handling to take into account for what element is focused. I don't think iTwinUI, as a generic component library, should handle these specific things. Our Input is meant to be used across all kinds of applications, not just iTwin Viewer, and someone else might rely on the propagation behavior.