From afc5b491396ba01e38876cc0ce550c9c7abf9f70 Mon Sep 17 00:00:00 2001 From: Aleksey Ilin Date: Fri, 4 Nov 2022 18:00:59 +0100 Subject: [PATCH 1/3] added attribute to disable internal styling --- src/index.js | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/index.js b/src/index.js index 5e0ccc0e5..b983b400d 100755 --- a/src/index.js +++ b/src/index.js @@ -74,7 +74,8 @@ class ReactTooltip extends React.Component { bodyMode: PropTypes.bool, possibleCustomEvents: PropTypes.string, possibleCustomEventsOff: PropTypes.string, - clickable: PropTypes.bool + clickable: PropTypes.bool, + disableInternalStyle: PropTypes.bool }; } @@ -152,12 +153,15 @@ class ReactTooltip extends React.Component { } componentDidMount() { - const { insecure, resizeHide } = this.props; + const { insecure, resizeHide, disableInternalStyle } = this.props; this.mount = true; this.bindListener(); // Bind listener for tooltip this.bindWindowEvents(resizeHide); // Bind global event for static method - this.injectStyles(); // Inject styles for each DOM root having tooltip. + + if (!disableInternalStyle) { + this.injectStyles(); // Inject styles for each DOM root having tooltip. + } } static getDerivedStateFromProps(nextProps, prevState) { @@ -798,14 +802,16 @@ class ReactTooltip extends React.Component { const { extraClass, html, ariaProps, disable, uuid } = this.state; const content = this.getTooltipContent(); const isEmptyTip = this.isEmptyTip(content); - const style = generateTooltipStyle( - this.state.uuid, - this.state.customColors, - this.state.type, - this.state.border, - this.state.padding, - this.state.customRadius - ); + const style = this.props.disableInternalStyle + ? '' + : generateTooltipStyle( + this.state.uuid, + this.state.customColors, + this.state.type, + this.state.border, + this.state.padding, + this.state.customRadius + ); const tooltipClass = '__react_component_tooltip' + @@ -828,7 +834,9 @@ class ReactTooltip extends React.Component { .join(' '); if (html) { - const htmlContent = `${content}\n`; + const htmlContent = `${content}${ + style ? `\n` : '' + }`; return ( (this.tooltipRef = ref)} data-id="tooltip" > -