question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Popover] Broken onEntering event propagation

See original GitHub issue
  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Select options position on screen should open close to the input position

Current Behavior

Select options position on screen opens in top left window corner

muiselect

Steps to Reproduce

Link: https://codesandbox.io/s/6vo1kkz64k (everything related is in src/pages/repro.js file)

  1. Add Select component
  2. Load options of that Select component dynamically after first render (e.g. via AJAX)
  3. Click on that Select component
  4. Observe in which position on the page the Select component options open

Context

We are using dynamic options loading in our app for dynamic filtering. Without going into too much detail:

We have 2 filters. One filter is “location” filter (not related to window.location). Second filter is “user” filter. Both filters are implemented with Select components.

The second “user” filter depends on the value of first “location” filter. If the value of first “location” filter changes, then we reload “user” filter options that depend on the selected “location” filter value.

We use that functionality in multiple places in the app.

Your Environment

Tech Version
Material-UI Tested on v3.4.0 & v.3.5.0 & v3.5.1
React Tested on v16.5.2 & v16.6.3
Browser Tested on Chrome 69 & 70 & MS Edge 42
TypeScript
etc.

This started to happen when we upgraded to @material-ui/core v.3.4.0.

Since then we’ve downgraded to v3.3.2 where this doesn’t happen.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Nov 19, 2018

@DominikSerafin Thank you for taking the time to open this pull request and sharing it! The root of the issue is in the Popover: https://github.com/mui-org/material-ui/blob/7d2070fb388295d38806ecc49717006f34393e74/packages/material-ui/src/Popover/Popover.js#L321-L333


We have a createChainedFunction() helper function to handle this use case.

--- a/packages/material-ui/src/Popover/Popover.js
+++ b/packages/material-ui/src/Popover/Popover.js
@@ -8,6 +8,7 @@ import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce
 import EventListener from 'react-event-listener';
 import ownerDocument from '../utils/ownerDocument';
 import ownerWindow from '../utils/ownerWindow';
+import { createChainedFunction } from '../utils/helpers';
 import withStyles from '../styles/withStyles';
 import Modal from '../Modal';
 import Grow from '../Grow';
@@ -294,7 +295,7 @@ class Popover extends React.Component {
       transformOrigin,
       TransitionComponent,
       transitionDuration: transitionDurationProp,
-      TransitionProps,
+      TransitionProps = {},
       ...other
     } = this.props;

@@ -323,13 +324,13 @@ class Popover extends React.Component {
           in={open}
           onEnter={onEnter}
           onEntered={onEntered}
-          onEntering={this.handleEntering}
           onExit={onExit}
           onExited={onExited}
           onExiting={onExiting}
           role={role}
           timeout={transitionDuration}
           {...TransitionProps}
+          onEntering={createChainedFunction(this.handleEntering, TransitionProps.onEntering)}
         >
           <Paper
             className={classes.paper}

The alternative is to warn so people don’t use this pattern. What do you think? Do you want to submit a pull request to handle this problem? 😃

0reactions
IssueHuntBotcommented, Mar 11, 2019

@oliviertassinari has rewarded $72.00 to @ekoeditaa. See it on IssueHunt

  • 💰 Total deposit: $80.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $8.00
Read more comments on GitHub >

github_iconTop Results From Across the Web

[Popover] Broken onEntering event propagation · Issue #13635
bug 🐛 Something isn't working component: Popover. good first issue. Enable to learn the contribution process.
Read more >
stopPropagation not preventing bubbling with Bootstrap popover
I am attempting to prevent clicks on a React Bootstrap popover from bubbling up and triggering the onClick handler on a parent element....
Read more >
Breaking changes in v5, part two: core components - Material UI
This is a reference guide to all of the breaking changes introduced in Material v5, and how to handle them when migrating from...
Read more >
The Dangers of Stopping Event Propagation - CSS-Tricks
Yet, unfortunately, it's absolutely terrible advice. This solution is roughly equivalent to fixing a leaky shower by turning off the water to ...
Read more >
Event Bubbling and Event Catching in JavaScript and React
In this article, I'll help you understand event bubbling and event catching like a pro. I created this resource to help you understand...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found