Skip to content

Commit

Permalink
fix(question): hotfix invalid image dimensions and layout update issue
Browse files Browse the repository at this point in the history
- Fix image dimensions to ensure proper display
- Resolve issue where images were not showing in question update forms
- Correct the update logic for the "layout" data field
  • Loading branch information
loklokyx committed Feb 12, 2025
1 parent a5786be commit 60cb6b7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions client/src/components/ui/Question/preview-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const ImageControls = ({
<Image
src={imageUrl}
alt="Question Image Preview"
width={0}
height={0}
width={200}
height={300}
className="h-auto max-h-[30vh] w-auto max-w-[30vw]"
/>
{controls.map(({ Component, position, layout }) => (
Expand Down
6 changes: 5 additions & 1 deletion client/src/pages/question/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ function EditQuestionForm({ question }: { question: Question }) {
solution: watchedValues.solution_text || "",
mark: watchedValues.mark || "",
layout: (watchedValues.layout ?? Layout.TOP) as Layout,
image: imageUrl,
image: imageUrl
? imageUrl
: question.images && question.images.length > 0
? question.images[0].url
: null,
}}
setLayout={(newLayout: Layout) =>
form.setValue("layout", newLayout)
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/question/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default function Create() {
note: "note",
solution_text: data.solution_text,
diff_level: parseInt(data.difficulty),
layout: "layout",
layout: data.layout,
mark: parseInt(data.mark, 0),
},
{
Expand Down

0 comments on commit 60cb6b7

Please sign in to comment.