Skip to content

Commit

Permalink
rename DoenetViewer attribute back to render
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp committed Jan 20, 2025
1 parent a5a3ee0 commit ca82a72
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 35 deletions.
24 changes: 9 additions & 15 deletions packages/doenetml/src/Viewer/DocViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function DocViewer({
userId,
activityId = "a",
docId = "1",
rendered = true,
render = true,
hidden = false,
attemptNumber = 1,
forceDisable = false,
Expand All @@ -61,7 +61,7 @@ export function DocViewer({
userId?: string;
activityId?: string;
docId?: string;
rendered?: boolean;
render?: boolean;
hidden?: boolean;
attemptNumber?: number;
forceDisable?: boolean;
Expand All @@ -75,18 +75,12 @@ export function DocViewer({
updateCreditAchievedCallback?: Function;
setIsInErrorState?: Function;
prefixForIds?: string;
render?: boolean;
isCurrent?: boolean;
hideWhenNotCurrent?: boolean;
addVirtualKeyboard?: boolean;
externalVirtualKeyboardProvided?: boolean;
location?: any;
navigate?: any;
linkSettings?: { viewURL: string; editURL: string };
scrollableContainer?: HTMLDivElement | Window;
darkMode?: "dark" | "light";
showAnswerTitles?: boolean;
includeVariantSelector?: boolean;
}) {
const updateRendererSVsWithRecoil = useRecoilCallback(
({ snapshot, set }) =>
Expand Down Expand Up @@ -559,7 +553,7 @@ export function DocViewer({
}, [location, hash, coreCreated.current, coreWorker]);

useEffect(() => {
if (hash && documentRenderer && rendered) {
if (hash && documentRenderer && render) {
let anchor = hash.slice(1);
if (
(!previousLocationKeys.current.includes(location.key) ||
Expand All @@ -571,7 +565,7 @@ export function DocViewer({
}
previousLocationKeys.current.push(location.key);
}
}, [location, hash, documentRenderer, rendered]);
}, [location, hash, documentRenderer, render]);

useEffect(() => {
callAction({
Expand Down Expand Up @@ -1099,7 +1093,7 @@ export function DocViewer({

//Guard against the possibility that parameters changed while waiting
if (coreIdWhenCalled === coreId.current) {
if (rendered) {
if (render) {
startCore(initialPass);
} else {
setStage("readyToCreateCore");
Expand Down Expand Up @@ -1334,7 +1328,7 @@ export function DocViewer({

// if we are just starting and the document isn't being rendered,
// don't do anything more
if (initialPass && !rendered) {
if (initialPass && !render) {
return null;
}

Expand Down Expand Up @@ -1409,17 +1403,17 @@ export function DocViewer({
return null;
}

if (stage === "readyToCreateCore" && rendered) {
if (stage === "readyToCreateCore" && render) {
startCore();
} else if (stage === "waitingOnCore" && !rendered && !coreCreated.current) {
} else if (stage === "waitingOnCore" && !render && !coreCreated.current) {
// we've moved off this doc, but core is still being created
// so reinitialize core
reinitializeCoreAndTerminateAnimations();

setStage("readyToCreateCore");
}

if (hidden || !rendered) {
if (hidden || !render) {
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/doenetml/src/doenetml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function DoenetViewer({
prefixForIds = "",
userId,
attemptNumber = 1,
rendered = true,
render = true,
hidden = false,
requestedVariantIndex,
updateCreditAchievedCallback,
Expand Down Expand Up @@ -128,7 +128,7 @@ export function DoenetViewer({
prefixForIds?: string;
userId?: string;
attemptNumber?: number;
rendered?: boolean;
render?: boolean;
hidden?: boolean;
requestedVariantIndex?: number;
updateCreditAchievedCallback?: Function;
Expand Down Expand Up @@ -242,7 +242,7 @@ export function DoenetViewer({
prefixForIds={prefixForIds}
userId={userId}
attemptNumber={attemptNumber}
rendered={rendered}
render={render}
hidden={hidden}
requestedVariantIndex={variantIndex.current}
updateCreditAchievedCallback={updateCreditAchievedCallback}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("PageViewer Attribute Tests", function () {
});

cy.get("#testRunner_toggleControls").click();
cy.get("#testRunner_rendered").click();
cy.get("#testRunner_render").click();
cy.wait(100);
cy.get("#testRunner_toggleControls").click();

Expand Down
18 changes: 9 additions & 9 deletions packages/test-cypress/src/CypressTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function CypressTest() {
allowSaveSubmissions: boolean;
allowSaveEvents: boolean;
autoSubmit: boolean;
rendered: boolean;
render: boolean;
darkMode: "light" | "dark";
showEditor: boolean;
viewerLocation: "left" | "right" | "bottom" | "top";
Expand All @@ -36,7 +36,7 @@ export function CypressTest() {
allowSaveSubmissions: false,
allowSaveEvents: false,
autoSubmit: false,
rendered: true,
render: true,
darkMode: "light",
showEditor: false,
viewerLocation: "right",
Expand Down Expand Up @@ -89,7 +89,7 @@ export function CypressTest() {
testSettings.allowSaveEvents,
);
const [autoSubmit, setAutoSubmit] = useState(testSettings.autoSubmit);
const [rendered, setRendered] = useState(testSettings.rendered);
const [render, setRender] = useState(testSettings.render);

const [showEditor, setShowEditor] = useState(testSettings.showEditor);
const [viewerLocation, setViewerLocation] = useState(
Expand Down Expand Up @@ -411,20 +411,20 @@ export function CypressTest() {
<label>
{" "}
<input
id="testRunner_rendered"
id="testRunner_render"
type="checkbox"
checked={rendered}
checked={render}
onChange={() => {
testSettings.rendered = !testSettings.rendered;
testSettings.render = !testSettings.render;
localStorage.setItem(
"test settings",
JSON.stringify(testSettings),
);
setRendered((was: boolean) => !was);
setRender((was: boolean) => !was);
setUpdateNumber((was: number) => was + 1);
}}
/>
Rendered
Render
</label>
</div>
<hr />
Expand Down Expand Up @@ -526,7 +526,7 @@ export function CypressTest() {
attemptNumber={attemptNumber}
requestedVariantIndex={requestedVariantIndex.current}
activityId="activityIdFromCypress"
rendered={rendered}
render={render}
location={location}
navigate={navigate}
linkSettings={{
Expand Down
14 changes: 7 additions & 7 deletions packages/test-viewer/src/test/testViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function TestViewer() {
readOnly: boolean;
showFeedback: boolean;
showHints: boolean;
rendered: boolean;
render: boolean;
showEditor: boolean;
viewerLocation: "left" | "right" | "bottom" | "top";
} = {
Expand All @@ -21,7 +21,7 @@ export default function TestViewer() {
readOnly: false,
showFeedback: true,
showHints: true,
rendered: true,
render: true,
showEditor: false,
viewerLocation: "right",
};
Expand All @@ -36,7 +36,7 @@ export default function TestViewer() {
readOnly,
showFeedback,
showHints,
rendered,
render,
showEditor,
viewerLocation,
} = testSettings;
Expand Down Expand Up @@ -140,17 +140,17 @@ export default function TestViewer() {
{" "}
<input
type="checkbox"
checked={rendered}
checked={render}
onChange={() => {
setTestSettings((was) => {
let newObj = { ...was };
newObj.rendered = !was.rendered;
newObj.render = !was.render;
return newObj;
});
setUpdateNumber((was) => was + 1);
}}
/>
Rendered
Render
</label>
</div>
<div>
Expand Down Expand Up @@ -225,7 +225,7 @@ export default function TestViewer() {
autoSubmit: false,
}}
activityId=""
rendered={rendered}
render={render}
addVirtualKeyboard={true}
/>
);
Expand Down

0 comments on commit ca82a72

Please sign in to comment.