-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
node.contains is not a function in Portal click #3786
Comments
Please provide a repro case. |
@layershifter any chance for investigation w/o repro? |
How? 🤔 As I see it because wrong ref to There is only one obvious case than can be an issue: const CustomButton = React.forwardRef((props, ref) => {
return <Button {...props} ref={ref} />
}) Try to simplify your |
Yup. looks like it's StyledComponent button as trigger that is the cause import { Button } from "semantic-ui-react";
import styled from "styled-components/macro";
import semanticStyles from "../../../semantic/exports.module.less";
export const LinkButton = styled(Button).attrs({
//className: "tertiary"
})`
color: ${semanticStyles.blue} !important;
font-weight: normal !important;
padding: 0 !important;
background-color: transparent !important;
`; <React.Fragment>
<Modal
centered={false}
trigger={<LinkButton onClick={this.handleOpen}>{this.props.elementText}</LinkButton>}
dimmer={"inverted"}
open={this.state.modalOpen}
onClose={this.handleClose}
size={"large"}>
<Modal.Header>{r.offerName}</Modal.Header>
<Modal.Content scrolling>
<OfferSkuMatchComponent
isAdmin={isAdmin}
/>
</Modal.Content>
<Modal.Actions>
<Button primary onClick={this.handleClose}>
Закрыть
</Button>
</Modal.Actions>
</Modal>
</React.Fragment> |
Now, looks like it's Styled design decision, I just don't get how do I forward ref to styled button |
Let me create a repro and ensure 👍 |
Here is a workaround for you. Can you please check? const ButtonWithRef = React.forwardRef((props, ref) => (
<Ref innerRef={ref}>
<Button {...props} />
</Ref>
));
export const WorkingButton = styled(ButtonWithRef)`
color: green !important;
`; |
@layershifter Thank you for your efforts! It worked! |
Does this mean that now I must use this workaround every time I use StyledComponents and Modals? |
Yep and |
Well, this is really unfortunate :(
when I use the button without trigger and modal |
Can you please edit CodeSandbox to show your issue? |
@layershifter I've managed to make it work like this: const ButtonWithRef = (React.forwardRef((props, ref) =>
ref ? (
<Ref innerRef={ref}>
<Button {...props} />
</Ref>
) : (
<Button {...props} />
)
) as any) as typeof Button; |
Good to know, closing for now. |
In my case (Styled Component issue) this simple trick has done the job:
|
Any updates? Would be nice, if you could fix this issue. |
TypeScript: import React from 'react'
import { Button, Ref } from 'semantic-ui-react'
const ButtonWithRef = React.forwardRef<HTMLElement>((props, ref) => (
<Ref innerRef={ref}>
<Button {...props} />
</Ref>
)) as any as typeof Button |
Bug Report
Can't actually create a valid bug report, looks like passed node is not a real DOM node.
The issue appeared after this PR I suppose: #2384
Here is a similar issue in react dropzone react-dropzone/react-dropzone#763
and here https://stackoverflow.com/questions/50133673/this-node-contains-does-not-work-if-this-node-is-a-ref-to-react-component
Expected Result
Clicks work as intended
Actual Result
No click events are fired
Node here is:
Version
0.88.1
The text was updated successfully, but these errors were encountered: