-
Notifications
You must be signed in to change notification settings - Fork 58
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
Avoid re-registering bslib components and globals #1045
Conversation
And refactored assignment into `registerBslibGlobal()` function
@@ -528,7 +528,5 @@ class SidebarInputBinding extends InputBinding { | |||
} | |||
|
|||
registerBinding(SidebarInputBinding, "sidebar"); |
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'd be curious to know how registerBinding()
handles this (i.e., does the last one win)? Seems like it'd be wise to match whatever it does?
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.
Would we want adding bslib::value_box()
to a Quarto dashboard to use Quarto's components -- that they test against and expect to work -- or to use bslib's component js instead?
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.
Ah, good point, makes sense for the 1st one to win then. But also, if the last one wins for registerBinding()
, wouldn't the binding be using the wrong Sidebar
(i.e., we should maybe update registerBinding()
to do something similar to registerBslibGlobal()
)?
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.
registerBinding()
is basically a safe call to BindingsRegistry.register()
in shiny. "registering" a binding just adds it to the end of an array. The .getBindings()
method breaks ties using the priority
propery, followed by most-recently-registered.
Anyway, you're pointing out that this isn't an unambiguous or complete fix, and I agree. This PR at least gets us out of the position of breaking Dashboards. We'll have to do some thinking in the future
Fixes #1044
Avoids redefining bslib-provided custom elements or web components (e.g.
bslib-tooltip
,bslib-popover
) as well as globally-registered classes (bslib.Sidebar
andbslib.Card
).In both cases a console error message is provided: