-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modal does not work with React 16 #188
Comments
https://github.com/callemall/material-ui/pull/7218/files might be helpful here. |
Fo v16 we'll want to switch to the new (YAH!) portal api |
Edit: I had a subpackage still referencing the older version of react-bootstrap. Latest is still broken with React 16 though :(
|
we can't hotfix RB to v0.8 because there are a few breaking changes, we need to do it on a major bump of RB |
Could you push an @next version to npm? |
I'm not sure that would even help no version of RO uses the new portal api yet. string refs should work still with the old API I would open an issue on the React repo since its a v16 bug |
Ah - Part of my app was on 30.10, and the string ref was still there. The latest release is still broken in 16 though. It looks like the child component of Portal passed in by Modal is not mounted by the time Modal.componentDidUpdate is called - this makes sense, as AFAIK that lifecycle callback doesn't fire until the commit phase. The proper thing to do is to have the child you pass to the Portal component kick off onShow instead of doing it from cDU or cDM in the Modal component itself. |
@jquense Sent you a chat request |
@billschaller sorry just saw the request. You are better off pinging me in the react-bootstrap discord channel https://discord.gg/0ZcbPKXt5bXLs9XK i'm |
Is there any news on the landing of RO on RB? I'd like to help but I don't know what are the tasks to be done. |
facebook/react#10675 is probably also relevant. |
@KagamiChan please feel free to jump in here. The tasks are to upgrade to the new createPortal api while (if possible) also supporting v15. So some amount of feature detecting and branching is needed. Portal should be the only component that needs an upgrade. |
thank you for your reply, will take some time to learn about this |
I just created #201 to make some progress on this. Any help is appreciated. |
@jquense, I don't think that this is the solution (see #201). I think that @billschaller pointed out the issue in #188 (comment). I got some of the tests to run by wrapping the |
FYI React 16 is released, so this just became a blocker for people to be able to upgrade. |
This shim has worked fine for us - it bypasses some functionality but it got us unblocked.
|
😄 I'm also using this in the meantime : import { Modal as ReactOverlayModal } from 'react-overlays';
class Modal extends ReactOverlayModal {
focus = () => {};
}
export default Modal; |
you can see that there are a few efforts to fix this. IF you want stuff to go faster jump in on the PR's and review/test them |
I dug into this a bit to see what the root problem was. The core problem is What this means is that (given that setModalNode = (ref) => {
this.modalNode = ref;
if (ref && this.props.show) {
this.onShow();
}
} as a temporary shim, this should work for most setups. import { Modal } from 'react-overlays';
Modal.prototype.componentWillMount = function() {
this.setModalNode = function(ref: any) {
this.modalNode = ref;
if (ref != null && this.props.show) {
this.onShow();
}
}.bind(this);
};
Modal.prototype.componentDidMount = function() {
this._isMounted = true;
}; |
I'd just like to note that @patsissons solution obviously does not work when you're doing something like this:
as // edit: fixed code |
Hey! Anything we can do to help? |
@jeremy-colin There seems to be some WIP pull requests. |
hi guys, i tried to use the patches provided here but couldn't able to do that. can anyone help me out in this matter. i already post my question here. looking for help. @patsissons @pamelus @davidworkman9 @connorjburton @Calyhre thanks for help in advance. |
@mglrahul you are probably best off waiting for the official patch to be honest |
@connorjburton actually i urgently need to fix the issue in my project. so if i get any working patch solution than that's fine, we can fix the temporary with the official update later. but right now i need a fix. if you can give me some idea it will be great. i already try to integrate the patches mentioned above in my project, but couldn't be able to make it workable. |
@mglrahul see my post above (#188 (comment)) it addresses how to get this up and running with minimal side effects. The shim in the post should patch the |
hey @patsissons thanks for replying, i read #188 commit, but couldn't understand where to put the patch you provided. do i need to put it in component or js library. below is my component.
this is the question i asked on stackoverflow. |
If you are using webpack you need to use this fix like this: import Modal from 'react-bootstrap/node_modules/react-overlays/lib/Modal';
Modal.prototype.componentWillMount = function componentWillMount() {
this.focus = function focus() {};
}; |
@seeden i try to use your solution in the component but i get some error, below is the error i got
i have put the code out of render in component. |
@mglrahul put it out of component |
@mglrahul You can do that kind of walk around in your entry point for js files. main.js or index.js. Just make sure you have imported Modal from react-overlays |
Is this patch the "official" response for react-bootstrap on react16 or is there WIP to get this fixed properly? |
finally i able to make it work, thanks to all the kind people @szczepanbarszczowski @zdila @seeden @patsissons @connorjburton without all your help it won't work |
version 0.7.3 seems to have fixed the issue. Thanks for the work on this! |
react-bootstrap/react-overlays#188 (thanks to react 16).
react-bootstrap/react-overlays#188 (thanks to react 16).
react-bootstrap/react-overlays#188 (thanks to react 16).
still not working
|
@geminiyellow this has been fixed in 0.7.3, but not yet in the 0.8 branch (as of 0.8.2). I worked around that issue by creating a custom
Once 0.7.3 was released, I just downgraded the react-overlays version from ^0.8.2 to ^0.7.3, so that patch isn't needed any more. |
@billschaller thank you 👍 |
Probably the same issue as facebook/react#9808.
When the Modal is shown and tries to get focus (via
componentDidUpdate
->onShow
-focus
),setModalNode
will not have been called andgetDialogElement
will returnundefined
.The text was updated successfully, but these errors were encountered: