-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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(insertTab): Render inserted nav html only once #4179
Open
gadenbuie
wants to merge
7
commits into
main
Choose a base branch
from
refactor/render-tabs-once
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+73
−87
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
20908ec
fix: Fix checking if `scope` is a jquery element
gadenbuie 7aa1ec5
refactor: Don't check binding validity if `scope` isn't an element
gadenbuie b9f3094
fix(insertTab): Render inserted nav html only once
gadenbuie 4040039
chore: Don't need to delay binding
gadenbuie 86d9cea
`yarn build` (GitHub Actions)
gadenbuie af6ecdb
fix: Bind all after inserting nav controls
gadenbuie 6722594
`yarn build` (GitHub Actions)
gadenbuie 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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.
Note B in the mega-comment below says "renderContent must be called on an element that's attached to the document". Is that going to be a problem here?
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.
It didn't seem to be in testing but I'll take another look. The mega comment is quite old; while the insert tab message handler hasn't changed much since it was written,
renderContent()
certainly has seen a few changes.The comment was added here 91dbb0e in #1794
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.
Actually it seems like
renderContentAsync()
is essentially the same butrenderHtml()
has changed. (Leaving crumbs for myself)https://github.com/rstudio/shiny/blob/91dbb0e77bfe137335e628ba314c6c9c399e2b71/srcjs/output_binding_html.js
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.
I found a very helpful comment from you @jcheng5 in that PR thread that I'll move up to a top-level comment here.
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.
The mega comment also states
but one core difference is that
renderHtml()
does now use jQuery for all insertion positions. The change was made in #3630.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.
Oh, I found it! Output elements need to be attached to the DOM, otherwise they aren't bound
shiny/srcts/src/shiny/bind.ts
Lines 317 to 320 in d764ea9
So we just need to call
bindAll()
again after inserting the nav controls, in case they contain outputs. af6ecdbThere 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.
Here's a fun twist: I don't think this is needed anymore. The issue from #1399 doesn't reproduce if I take out the above line (added in #1402). (This change smells like an indirect fix that was reasonable at the time but might not be needed anymore.)
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.
After further reflection, I'm fine with this the way you've written it. I was going to suggest doing all the tag manipulation with a parsed-but-not-rendered-or-inserted
$liTag
, then calling renderContentAsync without doing the appending the$liTag
as a separate step. And if it were me I'd still maybe try to do it, but it's a pretty marginal improvement in code clarity and no difference in behavior AFAICT. So I'll leave it up to you.