Repository navigation
Replies: 7 comments
|
Tooltip is a very quirky component, so I can see it might have this kind of issue. It might be good to put together a unit test case that replicates this and help prevent regressions when the problem is fixed (cc @ciampo @mirka who may be interested in this).
A render won't usually cause a focus loss. Even a full render of an app won't unless something purposely changes around the focused element when react has reconciled and is updating the DOM. A render is usually the term for calling a function component or calling the I feel it's worth mentioning this as there's often an impression that rendering in React is bad. It may be bad for performance if it happens too often, but shouldn't really cause other issues unless there's buggy code in a component. There's some info here on reconciliation - https://reactjs.org/docs/reconciliation.html. I imagine what's happening in tooltip is something like that 'Elements Of Different Types' section. |
|
Thank you for the ping! We are planning on rewriting I second what @talldan wrote above — here's an example of a bug caused by reconciliation that we fixed recently #43508 |
|
@talldan thanks for your feedback.
Terminology: by 'full re-rendering' I didn't mean the React 'render'. That's React terminology. I did mean re-rendering in the browser (or re-painting, if you like) as in: an element gets removed and re-injected, triggering a full re-rendering of a portion of the page. I know that happens when React isn't able to reconcile. You can actually test this Tooltip behavior on #43952
Animated GIF to better illustrate: |
|
@fabiankaegy yes this appears to still be a problem. To reproduce:
As I mentioned above, right now the only workaround is to force the tooltip to always be rendered by setting the |
|
I'm not sure this is really something that |

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Splitting this out from #43952, see there for a an actual use case.
Turns out that setting a Tooltip conditionally may trigger a full re-rendering of the button the tooltip is set to.
A full re-rendering is less than ideal for a couple reasons:
There are legitimate cases where we would want to set a Tooltip conditionally, for example:
Right now, the only workaround is to force the tooltip to always be rendered by setting the
showTooltipprop to true. However, it doesn't make much sense to show both visible text and a tooltip. For example, a button with text 'Save' and also a tooltip with text 'Save' is pointless.I guess one option would be refactoring the Tooltip component to always mount the tooltip and switch is visibility with CSS. I'm not sure there are other ways, any thoughts and considerations are very welcome.
The main point here is to avoid a full re-rendering of the button (or other interactive control) the Tooltip it associated with.
All reactions