-
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 #2348, #2329, #1817: bugs triggered by networkD3 sankey plot #2361
Conversation
@wch One problem with this approach that we may want to rectify is, if the bootstrap-datepicker repo disappears, we don't have a way to revert to a "clean import", since the version in git is the one we've patched. We might consider adding the bootstrap-datepicker release zip file to our repo as part of the import process (for 1.6.4 it's 97k). What do you think? Update Nevermind, I realized that if we ever needed to do this we could |
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.
Looks good, other than a few small things.
tools/README.md
Outdated
|
||
After updating, our patches to `bootstrap-datepicker` must be applied using the script `applyDatepickerPatches.R` | ||
|
||
After updating and applying patches, `yarn grunt` should be run per the instructions above. |
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.
Might want to mention why this is necessary (to generate the minified JS file).
tools/README.md
Outdated
|
||
1. Make any necessary changes to files in `inst/www/shared/datepicker` | ||
1. **Do not commit your changes.** | ||
1. Instead, create a patch with a command like `git diff > tools/datepicker-patches/012-a-description.patch` |
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.
Mention that the patches are applied in numeric order.
tools/updateBootstrapDatepicker.R
Outdated
unzip( | ||
dest_file, | ||
files = c( | ||
"js/bootstrap-datepicker.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.
Needs locales
subdir also.
99715d6
to
a13dd73
Compare
* All of these were caused by the presence of multiple body tags on the page, which happened because networkD3's sankey plot generates SVGs containing body tags via SVG's foreignObject tag * In various places, the 'body' jQuery selector string is used under the assumption there is only one 'body' tag on the page. The presence of multiple 'body' tags breaks reliant code in strange ways. * The fix was to use document.body or 'body:first' instead of 'body'.
a13dd73
to
908d635
Compare
This PR supersedes #2359 as it includes some new infrastructure for managing patches to
bootstrap-datepicker
Cause and fix
'body'
jQuery selector string is used under the assumption there is only onebody
tag on the page. The presence of multiplebody
tags breaks reliant code in strange ways.'body:first'
ordocument.body
do the job.Issues that were fixed
Further context
Note that this has troubled networkD3 users for a long time: christophergandrud/networkD3#214
The way Shiny behaves, that this PR addresses, is not strictly "wrong" — it should be safe to assume that in a given HTML page, only one
body
will appear. However, the existence of the problem is proof of how confusingforeignObject
is (the SVG spec example forforeignObject
demonstrates embeddingbody
in an SVG!), and so it seems like a good policy for Shiny to do the robust (if technically unnecessary) thing.New patch infrastructure
This PR also includes two new scripts,
tools/updateBootstrapDatepicker.R
andtools/applyDatepickerPatches.R
, that can be used together to manage our own changes to thebootstrap-datepicker
3rd party library. A section was added totools/README.md
documenting their use.In order to switch to this new method of applying patches, bootstrap-datepicker version 1.6.4 was re-imported, and a previously committed change was converted to a
.patch
and re-applied using the new tools.