fix: leave new dropdown answers empty instead of "undefined" - #3216
fix: leave new dropdown answers empty instead of "undefined"#3216ihor-romaniuk wants to merge 1 commit into
Conversation
Adding a dropdown problem in Studio filled all three answers with the word "undefined" instead of leaving them empty behind their "Enter an answer" placeholder, so an author had to clear each field before typing. The blank template writes empty option tags, and the parser turned a missing text node into a string with String(). Single select and multi-select escape it because they are rich text and their titles are rebuilt right after; dropdown answers are plain text, so the string survived into the field.
|
Thanks for the pull request, @ihor-romaniuk! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3216 +/- ##
========================================
Coverage 95.92% 95.92%
========================================
Files 1397 1397
Lines 33581 33581
Branches 7947 7678 -269
========================================
Hits 32214 32214
- Misses 1308 1323 +15
+ Partials 59 44 -15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Adding a dropdown problem in Studio used to fill all three answers with the word
undefined. The fields look filled in, their "Enter an answer" placeholder never shows, and an author has to clear each one before typing. Every other problem type starts with empty answers.New dropdown answers now start empty, like the rest.
Implementation notes
<option correct="True"></option>, so the parsed element has no#text.OLXParser.parseMultipleChoiceAnswersran that throughString(), which turnsundefinedinto the string"undefined".RichTextProblems: their titles are rebuilt from the preserved rich text on the very next line. Dropdown answers are plain text, so the string survived.?? ''rather than a falsy check, so an option whose text is0orfalsestill parses to that value.Screenshot/Video
Testing
undefined.Verified locally
undefined["", "", ""], matching single select; before it yielded["undefined", "undefined", "undefined"]OLXParser.test.jsString()call fails exactly that testjest src/editors/containers/ProblemEditortsc,dprint,oxlint