Skip to content

Commit

Permalink
Merge pull request #60 from concord-consortium/misc-04-09-2024-fixes
Browse files Browse the repository at this point in the history
Misc fixes:
  • Loading branch information
dougmartin authored Apr 10, 2024
2 parents bcb95a1 + c8bfc51 commit 6102b2b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export const App = () => {
</div>
</div>

<SpeedToggle fastSimulation={fastSimulation} onChange={handleSpeedToggle} disabled={animating} />
<SpeedToggle fastSimulation={fastSimulation} onChange={handleSpeedToggle} />

</div>
<div className="buttons">
Expand Down
5 changes: 5 additions & 0 deletions src/components/graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,11 @@ export const Graph = (props: Props) => {
const svg = d3.select(svgRef.current);
const root = svg.select("g.root");
const bounds = (root.node() as SVGGElement).getBBox();

if (!bounds.width || !bounds.height) {
return false;
}

const center = {
x: bounds.x + (bounds.width / 2),
y: bounds.y + (bounds.height / 2),
Expand Down
2 changes: 1 addition & 1 deletion src/components/speed-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
margin: 7px 0;
display: flex;
gap: 10px;
cursor: pointer;
cursor: default;

&>div {
width: 40px;
Expand Down
4 changes: 1 addition & 3 deletions src/components/speed-toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import "./speed-toggle.scss";

interface Props {
fastSimulation: boolean;
disabled: boolean;
onChange: (newValue: boolean) => void;
}

export const SpeedToggle = ({fastSimulation, disabled, onChange}: Props) => {
export const SpeedToggle = ({fastSimulation, onChange}: Props) => {
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
onChange(e.target.checked);
};
Expand All @@ -28,7 +27,6 @@ export const SpeedToggle = ({fastSimulation, disabled, onChange}: Props) => {
title={title}
checked={fastSimulation}
onChange={handleChange}
disabled={disabled}
/>
<div style={getStyle(fastSimulation)} className="fast">Fast</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/use-codap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export const useCODAP = ({onCODAPDataChanged, getGraph, setGraph, setInitialGrap

const handleDataChanged = useCallback(async ({datasetName, collectionName, attributeName}: CODAPAttribute) => {
const values = await getValuesForAttribute(datasetName, collectionName, attributeName);
if (viewMode === "dataset" && (JSON.stringify(values) !== JSON.stringify(valuesRef.current))) {
const valuesChanged = !valuesRef.current || (JSON.stringify(values) !== JSON.stringify(valuesRef.current));
if (viewMode === "dataset" && valuesChanged) {
onCODAPDataChanged(values);
valuesRef.current = values;
}
Expand Down Expand Up @@ -127,6 +128,7 @@ export const useCODAP = ({onCODAPDataChanged, getGraph, setGraph, setInitialGrap
collectionName: iMessage.values.collection.name,
attributeName: iMessage.values.attribute.name
};
valuesRef.current = [];
setAttribute(newAttribute);
await handleDataChanged(newAttribute);
await notifyStateIsDirty();
Expand Down

0 comments on commit 6102b2b

Please sign in to comment.