Skip to content
Merged
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
27 changes: 13 additions & 14 deletions app/charts/shared/annotation-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback } from "react";
import { useCallback, useRef } from "react";

import { useInteraction } from "@/charts/shared/use-interaction";
import {
Expand Down Expand Up @@ -26,10 +26,14 @@ export const useIsEditingAnnotation = () => {

export const useGetAnnotationRenderState = () => {
const [interaction] = useInteraction();
const interactionRef = useRef(interaction);
interactionRef.current = interaction;
const [state] = useConfiguratorState();
const chartConfig = getChartConfig(state);
const { activeField } = chartConfig;
const isEditing = useIsEditingAnnotation();
const annotationsRef = useRef(chartConfig.annotations);
annotationsRef.current = chartConfig.annotations;

const getAnnotationRenderState = useCallback(
(
Expand All @@ -44,7 +48,7 @@ export const useGetAnnotationRenderState = () => {
) => {
let annotation: Annotation | undefined;

for (const a of chartConfig.annotations) {
for (const a of annotationsRef.current) {
const matches = matchesAnnotationTarget(observation, a.targets);

if (matches) {
Expand All @@ -59,12 +63,14 @@ export const useGetAnnotationRenderState = () => {
color = annotation.color;
}

const currentInteraction = interactionRef.current;
const interactionMatches =
interaction.type === "annotation" &&
interaction.visible &&
interaction.observation?.[`${axisComponentId}/__iri__`] === axisValue;
currentInteraction.type === "annotation" &&
currentInteraction.visible &&
currentInteraction.observation?.[`${axisComponentId}/__iri__`] ===
axisValue;

const targetsOtherAnnotations = chartConfig.annotations.some(
const targetsOtherAnnotations = annotationsRef.current.some(
(a) =>
a.key !== activeField &&
matchesAnnotationTarget(observation, a.targets)
Expand All @@ -81,14 +87,7 @@ export const useGetAnnotationRenderState = () => {
isActive,
};
},
[
activeField,
chartConfig.annotations,
interaction.observation,
interaction.type,
interaction.visible,
isEditing,
]
[activeField, isEditing]
);

return getAnnotationRenderState;
Expand Down
16 changes: 13 additions & 3 deletions app/components/multi-select/option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,19 @@ export const MultiSelectOption = ({
typography: selectSizeToTypography[size],
}}
>
{isNoneValue
? t({ id: "controls.clear-selection", message: "Clear selection" })
: label}
<Typography
sx={{
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
flex: 1,
typography: selectSizeToTypography[size],
}}
>
{isNoneValue
? t({ id: "controls.clear-selection", message: "Clear selection" })
: label}
</Typography>
<Flex
sx={{
justifyContent: "flex-end",
Expand Down
11 changes: 9 additions & 2 deletions app/components/multi-select/tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ export const MultiSelectTags = ({
display: "inline-flex",
alignItems: "center",
gap: 0.5,
py: 1,
maxWidth: "100%",
overflow: "hidden",
}}
>
<Typography
variant={selectSizeToTypography[size]}
style={{ lineHeight: 1 }}
sx={{
lineHeight: 1,
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
minWidth: 0,
}}
>
{option.label}
</Typography>
Expand Down
36 changes: 33 additions & 3 deletions app/components/select-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,17 @@ const TreeItemContent = forwardRef<
>
<div className={clsx(classes.iconContainer)}>{icon}</div>
<div className={classes.label}>
<Typography variant={selectSizeToTypography[size]} component="span">
<Typography
variant={selectSizeToTypography[size]}
component="span"
sx={{
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
display: "inline-block",
maxWidth: "100%",
}}
>
{label}
</Typography>
{selectable && hasChildren ? (
Expand Down Expand Up @@ -648,11 +658,19 @@ export const SelectTree = ({
alignItems: "center",
gap: 0.5,
py: 1,
maxWidth: "100%",
overflow: "hidden",
}}
>
<Typography
variant={selectSizeToTypography[size]}
style={{ lineHeight: 1 }}
sx={{
lineHeight: 1,
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
minWidth: 0,
}}
>
{labelsByValue[nodeId]}
</Typography>
Expand Down Expand Up @@ -695,7 +713,19 @@ export const SelectTree = ({
return <Trans id="No filter">No filter</Trans>;
}

return <>{value ? labelsByValue[value as string] : undefined}</>;
return (
<Typography
variant={selectSizeToTypography[size]}
sx={{
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
display: "block",
}}
>
{value ? labelsByValue[value as string] : undefined}
</Typography>
);
}}
sx={{
"& svg": {
Expand Down
4 changes: 2 additions & 2 deletions app/configurator/components/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1230,9 +1230,9 @@ export const TimeFilter = (props: TimeFilterProps) => {
return (
<div>
{!disableInteractiveFilters && (
<Flex sx={{ justifyContent: "flex-end", mb: 3 }}>
<Box sx={{ mb: 3 }}>
<InteractiveTimeRangeToggle />
</Flex>
</Box>
)}
<Flex sx={{ gap: 1 }}>
{rangeActiveFilter ? (
Expand Down