-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix: trigger props resend when iframe src changes [LIBS-488] #1344
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f4a6680
fix: trigger props resend when iframe src changes [LIBS-488]
tomzemp 76cfe0e
Merge branch 'master' into LIBS-488/reset-iframe-src
tomzemp 496472a
fix: merge issues
tomzemp 3fdae5b
fix: reset communication on either pluginSource or pluginShortName ch…
tomzemp ba37ba0
Merge branch 'alpha' into LIBS-488/reset-iframe-src
tomzemp 7998fc8
Merge branch 'alpha' into LIBS-488/reset-iframe-src
tomzemp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,8 @@ export const Plugin = ({ | |
|
||
const [communicationReceived, setCommunicationReceived] = | ||
useState<boolean>(false) | ||
const [prevCommunicationReceived, setPrevCommunicationReceived] = | ||
useState<boolean>(false) | ||
|
||
const [inErrorState, setInErrorState] = useState<boolean>(false) | ||
const [pluginHeight, setPluginHeight] = useState<number>(150) | ||
|
@@ -71,6 +73,17 @@ export const Plugin = ({ | |
}, [height, width]) | ||
|
||
useEffect(() => { | ||
setCommunicationReceived(false) | ||
}, [pluginEntryPoint]) | ||
|
||
useEffect(() => { | ||
// if communicationReceived switches from false to true, the props have been sent | ||
const prevCommunication = prevCommunicationReceived | ||
setPrevCommunicationReceived(communicationReceived) | ||
if (prevCommunication === false && communicationReceived === true) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is done so that when communicationReceived toggles from false to true (after successful send of props), the props are not sent an additional time |
||
return | ||
} | ||
|
||
if (iframeRef?.current) { | ||
const iframeProps = { | ||
...propsToPass, | ||
|
@@ -113,6 +126,8 @@ export const Plugin = ({ | |
}) | ||
} | ||
} | ||
// prevCommunicationReceived update should not retrigger this hook | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [propsToPass, communicationReceived, inErrorState, alertsAdd]) | ||
|
||
if (data && !pluginEntryPoint) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the essential refinement of this ticket...whenever the
pluginEntryPoint
changes now, thecommunicationReceived
is set to false to note that communication has been lost.The
communicationReceived
toggling to false will then trigger a resending of the props to the plugin.