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

[Popover] Positioning delayed

Open therahl opened this issue 9 years ago • 41 comments

Problem description

Popover component renders children before applying position styling. This results in a 'flash' of the popover in the top left corner (x: 0, y:0) before positioning correctly. This is caused by the setPlacement function being wrapped in setTimeout. Removing the setTimeout wrapper resolves the issue. The timeout was added for this issue: #7663.

Initial render 'flash':

Split second later, correctly positioned:

Versions

  • Material-UI: 0.19.0
  • React: 15.5
  • Browser: Chrome 60.0.3112.90

therahl avatar Sep 04 '17 18:09 therahl

I'm seeing this exact behavior in 1.0.0-beta.8. Happy to submit a PR if you think removing it is the correct change.

Edit: just looked more closely at the 1.x beta code, and it doesn't seem to have a setTimeout for the placement positioning.

stevewillard avatar Sep 04 '17 19:09 stevewillard

I am also having this same problem. Removing the setTimeout indeed fixes the issue. Right now we are hotpatching Popover.prototype to remove the setTimeout.

austinh avatar Sep 05 '17 20:09 austinh

Side note, the setTimeout was added by @lostpebble to support React Fiber.

oliviertassinari avatar Sep 06 '17 06:09 oliviertassinari

Yes, I happened to have noticed this now on slower devices as well. It was a quick fix for making the pre-v1 version of material-ui compatible with React Fiber. It seems like it's showing its cracks...

Basically, the API has changed when working on lower level rendering order stuff. As far as I know the next version of material-ui has rewritten this part of the rendering process to be compatible with React Fiber without such hacks - using the newer API interface.

When using React v16 with the 0.19 versions of material-ui, without this setTimeout the popovers will always render fixed to a corner of the screen instead of relative to the container you called it from.

lostpebble avatar Sep 06 '17 11:09 lostpebble

Any update with this one?

austinh avatar Sep 19 '17 19:09 austinh

Indeed, any planned release date for a fix?

atrauzzi avatar Sep 30 '17 16:09 atrauzzi

This bug also happens for me with React v16, so I don't think the fix does what it intends to do in the first place. It happens consistently for me on React 15.6 and React 16

austinh avatar Oct 02 '17 22:10 austinh

As mentioned earlier, there were some underlying changes that have happened with React v16 which is causing however the Popover stuff used to render, to not render at the right anchor point anymore.

This setTimeout fix prevents this happening:

peek 2017-10-03 12-08

Unfortunately it was not a complete solution, and I realise this problem of the flashing Popover needs to be fixed.

The whole reason I put the setTimeout in there as a temporary fix was because I don't know the deeper workings of material-ui or what's changed as far as React v16 is concerned in this specific rendering case. The Popover stuff specifically is quite a complicated bunch of code and my main goal was to get material-ui to function on top of React v16 - for which resolving this anchor-point issue and getting rid of react-touch-event-plugin was needed.

If you want to support React v16, although flawed, this setTimeout is far better than what the gif above shows - and in that case it does what it intends to do. I never noticed that flash until I ran into problems with a slow CPU or blocking the UI thread with overly heavy code. I realise it is not ideal, but it at least allows a start of using pre-v1 material-ui with React v16. If anyone would like to dive into it and try re-wire it to how React v16 requires, it would be much appreciated as I just don't have to capacity to do that at the moment.

I am told that the new v1 versions of material-ui do solve this problem, as they built it from the ground up considering the newer React changes.

lostpebble avatar Oct 03 '17 10:10 lostpebble

Any chance we can get a fix? This introduced a bad regression.

bradbirnbaum avatar Oct 09 '17 12:10 bradbirnbaum

@lostpebble You have been doing an excellent job adding the support of react@16 with our legacy version!

@bradbirnbaum Given the impact of this issue, I could try to find some time to work on it, but no promise, I have a lot of other important issues I want to take care of on the v1 branch.

oliviertassinari avatar Oct 09 '17 18:10 oliviertassinari

Just want to say -- This is happening in react 15 as well, so it's not currently limited to 16 either.

atrauzzi avatar Oct 09 '17 20:10 atrauzzi

It also appears that there is no enter animation of the popover since the fix by @lostpebble

jtorhoff avatar Oct 24 '17 22:10 jtorhoff

Yeah, the open animation doesn't work. This definitely needs attention.

atrauzzi avatar Oct 25 '17 22:10 atrauzzi

@austinh Can you give more details about your hotpatching solution on Popover.prototype please ? since apparently this won't be fixed for M-UI < v1,x (?)

Sharlaan avatar Oct 26 '17 10:10 Sharlaan

I have since moved on from the hotpatching solution b/c I’m trying to transition to mui v1, but if you look at the Popover.js class in this library and override the functions with Popover.prototype.componentDidMount/etc and change the setTimeouts to just be function that pass through, you might get it to still work. You can also try extending Popover with class Popover2 extends Popover syntax and just use Popover2 so that you don’t have to overwrite the prototype chain.

On Oct 26, 2017, at 6:05 AM, Raphaël Morineau [email protected] wrote:

@austinh Can you give more details about your hotpatching solution on Popover.prototype please ? since apparently this won't be fixed for M-UI < v1,x (?)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

austinh avatar Oct 26 '17 13:10 austinh

Got same issue: [email protected] [email protected]

Popover blinks for some few visible frames (1000ms/24) on top-left corner of screen and then shows up in correct place without transition.

Popover closes with part of transition and then dissappears.

Found situtaion: if you update DOM with sth after (in my case <IconButton><ANyMUITSVGIcon/></IconButton) transition and positionning works normally, which is not a solution.

Waiting for ETA and fix itself. Thanks!

FlackMonkey avatar Nov 14 '17 09:11 FlackMonkey

I am trying to dig into this issue, but I am having trouble re-creating it. The Material-UI docs site has it working, even if I upgrade it to use React 15.6.2. (Upgrading to React 16.x is very involved...trying to hold off on that unless we must do it.)

Does anyone have concrete steps that made this appear?

m2mathew avatar Nov 15 '17 17:11 m2mathew

I have the problem using React 15.6.1 with the tap even plugin (2.0.1) and Material-UI 0.19.3.

I'll see if I can have someone build a minimal test project that re-creates the problem next week.

gschjetne avatar Nov 16 '17 10:11 gschjetne

I see this issue with React 15.6.2, tap event plugin 2.0.1 and and Material-UI 0.19.4

romanzenka avatar Nov 20 '17 18:11 romanzenka

There is reproducing https://github.com/leanmarine/material-ui-debug

ViacheslavMylostyvyi avatar Nov 21 '17 15:11 ViacheslavMylostyvyi