Skip to content

ScenesReact: Add skipUrlSync to variables #1182

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/scenes-react/src/variables/CustomVariable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function CustomVariable({
initialValue,
isMulti,
includeAll,
skipUrlSync,
children,
}: CustomVariableProps): React.ReactNode {
const scene = useSceneContext();
Expand All @@ -26,7 +27,16 @@ export function CustomVariable({
let variable: CustomVariableObject | undefined = scene.findVariable(name);

if (!variable) {
variable = new CustomVariableObject({ name, label, query, value: initialValue, isMulti, includeAll, hide });
variable = new CustomVariableObject({
name,
label,
query,
value: initialValue,
isMulti,
includeAll,
hide,
skipUrlSync,
});
}

useEffect(() => {
Expand All @@ -42,8 +52,9 @@ export function CustomVariable({
hide,
isMulti,
includeAll,
skipUrlSync,
});
}, [hide, includeAll, isMulti, label, query, variable]);
}, [skipUrlSync, hide, includeAll, isMulti, label, query, variable]);

// Need to block child rendering until the variable is added so that child components like RVariableSelect find the variable
if (!variableAdded) {
Expand Down
8 changes: 6 additions & 2 deletions packages/scenes-react/src/variables/DataSourceVariable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function DataSourceVariable({
initialValue,
isMulti,
includeAll,
skipUrlSync,
children,
}: DataSourceVariableProps): React.ReactNode {
const scene = useSceneContext();
Expand All @@ -40,6 +41,7 @@ export function DataSourceVariable({
isMulti,
hide,
includeAll,
skipUrlSync,
});
}

Expand All @@ -59,7 +61,8 @@ export function DataSourceVariable({
variable.state.regex === regex &&
variable.state.label === label &&
variable.state.hide === hide &&
variable.state.includeAll === includeAll
variable.state.includeAll === includeAll &&
variable.state.skipUrlSync === skipUrlSync
) {
return;
}
Expand All @@ -70,10 +73,11 @@ export function DataSourceVariable({
label,
hide,
includeAll,
skipUrlSync,
});

variable.refreshOptions();
}, [hide, includeAll, label, pluginId, regex, variable, variableAdded]);
}, [skipUrlSync, hide, includeAll, label, pluginId, regex, variable, variableAdded]);

// Need to block child rendering until the variable is added so that child components like RVariableSelect find the variable
if (!variableAdded) {
Expand Down
8 changes: 6 additions & 2 deletions packages/scenes-react/src/variables/QueryVariable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function QueryVariable({
initialValue,
isMulti,
includeAll,
skipUrlSync,
children,
}: QueryVariableProps): React.ReactNode {
const scene = useSceneContext();
Expand All @@ -48,6 +49,7 @@ export function QueryVariable({
isMulti,
hide,
includeAll,
skipUrlSync,
});
}

Expand All @@ -70,7 +72,8 @@ export function QueryVariable({
variable.state.hide === hide &&
variable.state.includeAll === includeAll &&
variable.state.refresh === refresh &&
variable.state.sort === sort
variable.state.sort === sort &&
variable.state.skipUrlSync === skipUrlSync
) {
return;
}
Expand All @@ -84,10 +87,11 @@ export function QueryVariable({
regex,
hide,
includeAll,
skipUrlSync,
});

variable.refreshOptions();
}, [datasource, hide, includeAll, label, query, refresh, regex, sort, variable, variableAdded]);
}, [skipUrlSync, datasource, hide, includeAll, label, query, refresh, regex, sort, variable, variableAdded]);

// Need to block child rendering until the variable is added so that child components like RVariableSelect find the variable
if (!variableAdded) {
Expand Down
1 change: 1 addition & 0 deletions packages/scenes-react/src/variables/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface VariableProps {
label?: string;
hide?: VariableHide;
initialValue?: VariableValue;
skipUrlSync?: boolean;
}