mirror of
https://github.com/rstudio/shiny.git
synced 2026-01-09 15:08:04 -05:00
fix(conditionalPanel): Coerce condition result to boolean (#4127)
Co-authored-by: Kamil Zyla <kamil@appsilon.com>
This commit is contained in:
committed by
GitHub
parent
cc9b9d4e6a
commit
9d12b0fca7
2
NEWS.md
2
NEWS.md
@@ -10,6 +10,8 @@
|
||||
|
||||
* Fixed a bug introduced in v1.9.0 where the boundaries of hover/click/brush regions on plots were being incorrectly scaled when browser zoom was used. (#4111)
|
||||
|
||||
* Fixed a bug in `conditionalPanel()` that would cause the panel to repeatedly show/hide itself when the provided condition was not boolean. (@kamilzyla, #4127)
|
||||
|
||||
# shiny 1.9.0
|
||||
|
||||
## New busy indication feature
|
||||
|
||||
@@ -23917,7 +23917,7 @@
|
||||
}
|
||||
var nsPrefix = el.attr("data-ns-prefix");
|
||||
var nsScope = this._narrowScope(scope, nsPrefix);
|
||||
var show3 = condFunc(nsScope);
|
||||
var show3 = Boolean(condFunc(nsScope));
|
||||
var showing = el.css("display") !== "none";
|
||||
if (show3 !== showing) {
|
||||
if (show3) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
inst/www/shared/shiny.min.js
vendored
2
inst/www/shared/shiny.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -614,7 +614,7 @@ class ShinyApp {
|
||||
|
||||
const nsPrefix = el.attr("data-ns-prefix") as string;
|
||||
const nsScope = this._narrowScope(scope, nsPrefix);
|
||||
const show = condFunc(nsScope);
|
||||
const show = Boolean(condFunc(nsScope));
|
||||
const showing = el.css("display") !== "none";
|
||||
|
||||
if (show !== showing) {
|
||||
|
||||
@@ -148,7 +148,7 @@ function pixelRatio(): number {
|
||||
//
|
||||
// When the function is executed, it will evaluate that expression using
|
||||
// "with" on the argument value, and return the result.
|
||||
function scopeExprToFunc(expr: string): (scope: unknown) => boolean {
|
||||
function scopeExprToFunc(expr: string): (scope: unknown) => unknown {
|
||||
/*jshint evil: true */
|
||||
const exprEscaped = expr
|
||||
.replace(/[\\"']/g, "\\$&")
|
||||
@@ -159,7 +159,7 @@ function scopeExprToFunc(expr: string): (scope: unknown) => boolean {
|
||||
// \b has a special meaning; need [\b] to match backspace char.
|
||||
.replace(/[\b]/g, "\\b");
|
||||
|
||||
let func: () => boolean;
|
||||
let func: () => unknown;
|
||||
|
||||
try {
|
||||
// @ts-expect-error; Do not know how to type this _dangerous_ situation
|
||||
@@ -178,7 +178,7 @@ function scopeExprToFunc(expr: string): (scope: unknown) => boolean {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return function (scope: unknown): boolean {
|
||||
return function (scope: unknown): unknown {
|
||||
return func.call(scope);
|
||||
};
|
||||
}
|
||||
|
||||
2
srcts/types/src/utils/index.d.ts
vendored
2
srcts/types/src/utils/index.d.ts
vendored
@@ -10,7 +10,7 @@ declare function parseDate(dateString: string): Date;
|
||||
declare function formatDateUTC(x: Date): string;
|
||||
declare function makeResizeFilter(el: HTMLElement, func: (width: HTMLElement["offsetWidth"], height: HTMLElement["offsetHeight"]) => void): () => void;
|
||||
declare function pixelRatio(): number;
|
||||
declare function scopeExprToFunc(expr: string): (scope: unknown) => boolean;
|
||||
declare function scopeExprToFunc(expr: string): (scope: unknown) => unknown;
|
||||
declare function asArray<T>(value: T | T[] | null | undefined): T[];
|
||||
declare function mergeSort<Item>(list: Item[], sortfunc: (a: Item, b: Item) => boolean | number): Item[];
|
||||
declare function $escape(val: undefined): undefined;
|
||||
|
||||
Reference in New Issue
Block a user