iTwin / appui

Monorepo for iTwin.js AppUi
MIT License
8 stars 2 forks source link

Double onPropertyUpdated in PropertyGrid when pressing Tab #932

Closed karolis-zukauskas closed 1 month ago

karolis-zukauskas commented 1 month ago

Describe the bug

PropertyGridComponent from @itwin/property-grid-react calls onPropertyUpdated twice when you press TAB key (while editing a property). The two calls lead to some issues in our update implementation that uses EditCommands - you cannot start two overlapping EditCommands. This currently doesn't cause huge issues but our we end up showing this warning (when handling the second attempt to start EditCommand): image

It also seems that onPropertyUpdated is called when focus is lost, this leads to some nasty error cycle if the first call throws and we want to show some kind of error alert UI - I'm guessing that error alert moves focus, onPropertyUpdated runs again, it errors out, we show an error alert again ... image

NOTE: There is a similar issue already: https://github.com/iTwin/appui/issues/915

To Reproduce

  1. Start editing a property
  2. Press TAB
  3. Notice that it is called twice - first call is not awaited when second one is done.

See sample code and resulting console logs: image

Expected Behavior

No response

Screenshots

No response

Desktop (please complete the applicable information)

Reproduced in iTwin Studio, here are its versions:

Version: 1.0.63 (b7a3432) Build: iTwin Desktop Platform (Mango) 2024.07.10-2 iTwin.js: 4.7.4 iTwinUI: 3.10.0 AppUI: 4.12.0 React: 17.0.2 Node.js: 20.9.0 Electron: 29.1.0

Additional context

No response

grigasp commented 1 month ago

The fix released with @itwin/components-react@4.16.0