floating-ui icon indicating copy to clipboard operation
floating-ui copied to clipboard

[React-Native Android] : On switching between two spotlight targets, the floating dialog is initially rendered in the position of previous target

Open AmalMenachery opened this issue 2 years ago • 2 comments

Describe the bug In Android, On switching between two spotlight targets, the floating dialog is initially rendered in the position of the previous target.

To Reproduce

Steps to reproduce the behavior:

  1. Select the first target icon.
  2. Select the second target icon.
  3. The floating styles remain the same as before for three cycles, and then they re-render with the actual target of the second icon.

Expected behavior The floating dialog is rendered properly in the first render itself.

Screenshots

https://github.com/user-attachments/assets/6a9224a9-2e42-469d-bd42-4d1deaadece0

Context:

  • OS: Android (React-Native)
  • Browser : NA
  • Version: @floating-ui/react-native: 0.10.6

AmalMenachery avatar Aug 13 '24 10:08 AmalMenachery

For iOS it's wrapped in requestAnimationFrame, which may be causing the brief flicker:

https://github.com/floating-ui/floating-ui/blob/a8b7a88a73f780c59b89bb8c6e3db16ec589a43d/packages/react-native/src/useFloating.ts#L103

If you call the update() function manually, immediately upon it changing, is the issue still here?

atomiks avatar Aug 13 '24 13:08 atomiks

@atomiks - Yes. However, giving the SpotLight component a Key prop and resetting the target after closing the dialog solved the issue. But the component is re-rendered 4 times. Is there any other way to fix this?

Would updating the core and utils packages to the latest be effective?

AmalMenachery avatar Aug 13 '24 15:08 AmalMenachery