Skip to content

Commit

Permalink
[Dropdown] Bugfix - Render options and placeholder inline (#2054)
Browse files Browse the repository at this point in the history
## Summary: ##
The dropdown widget was not rendering content properly. Punctuation and other non-alphanumeric characters were causing the content to break to their own lines, even without TeX markup. Removing the `inline` setting for the `<Renderer>` usages resolved this.

Issue: LEMS-2741

## Test plan:
1. Open Storybook
1. Navigate to the Editor Demo page
1. Add a Dropdown widget
1. Type in TeX content for one of the option
1. Add another option with regular text (all alphanumeric characters)
1. Add another option with punctuation or other non-alphanumeric characters ($%^<>,.:)
1. Viewing the dropdown options in the preview section should show all of the options on their own lines (single line for each)
1. Repeat these steps for the Placeholder portion of the widget

Author: mark-fitzgerald

Reviewers: jeremywiebe

Required Reviewers:

Approved By: jeremywiebe

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x)

Pull Request URL: #2054
  • Loading branch information
mark-fitzgerald authored Dec 20, 2024
1 parent 8259c23 commit f23b383
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-taxis-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

[Dropdown] Bugfix - Render options and placeholder inline
30 changes: 18 additions & 12 deletions packages/perseus/src/__tests__/__snapshots__/renderer.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,14 @@ exports[`renderer snapshots correct answer: correct answer 1`] = `
class="perseus-renderer perseus-renderer-responsive"
>
<div
class=""
class="paragraph"
data-perseus-paragraph-index="0"
>
less than or equal to
<div
class="paragraph"
>
less than or equal to
</div>
</div>
</div>
</span>
Expand Down Expand Up @@ -471,10 +475,14 @@ exports[`renderer snapshots incorrect answer: incorrect answer 1`] = `
class="perseus-renderer perseus-renderer-responsive"
>
<div
class=""
class="paragraph"
data-perseus-paragraph-index="0"
>
greater than or equal to
<div
class="paragraph"
>
greater than or equal to
</div>
</div>
</div>
</span>
Expand Down Expand Up @@ -559,16 +567,14 @@ exports[`renderer snapshots initial render: initial render 1`] = `
class="perseus-renderer perseus-renderer-responsive"
>
<div
class=""
class="paragraph"
data-perseus-paragraph-index="0"
>
greater
</div>
<div
class=""
data-perseus-paragraph-index="1"
>
/less than or equal to
<div
class="paragraph"
>
greater/less than or equal to
</div>
</div>
</div>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,14 @@ exports[`Dropdown widget should snapshot when opened: dropdown open 1`] = `
class="perseus-renderer perseus-renderer-responsive"
>
<div
class=""
class="paragraph"
data-perseus-paragraph-index="0"
>
greater
</div>
<div
class=""
data-perseus-paragraph-index="1"
>
/less than or equal to
<div
class="paragraph"
>
greater/less than or equal to
</div>
</div>
</div>
</span>
Expand Down Expand Up @@ -138,16 +136,14 @@ exports[`Dropdown widget should snapshot: initial render 1`] = `
class="perseus-renderer perseus-renderer-responsive"
>
<div
class=""
class="paragraph"
data-perseus-paragraph-index="0"
>
greater
</div>
<div
class=""
data-perseus-paragraph-index="1"
>
/less than or equal to
<div
class="paragraph"
>
greater/less than or equal to
</div>
</div>
</div>
</span>
Expand Down
2 changes: 0 additions & 2 deletions packages/perseus/src/widgets/dropdown/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class Dropdown extends React.Component<Props> implements Widget {
<Renderer
content={this.props.placeholder}
strings={this.context.strings}
inline
/>
}
labelAsText={this.props.placeholder}
Expand All @@ -92,7 +91,6 @@ class Dropdown extends React.Component<Props> implements Widget {
<Renderer
content={choice}
strings={this.context.strings}
inline
/>
}
labelAsText={choice}
Expand Down

0 comments on commit f23b383

Please sign in to comment.