Page MenuHomePhabricator

[MEX] M4.1.5 - Mathematical expression: Simple text input (string) with value specific output
Closed, ResolvedPublic

Description

As a user, i want to add Mathematical expressions to wikidata, and see them displayed on the main page.

Screenshot 2026-01-13 at 14.39.57.png (1×2 px, 222 KB)

  • the input field for mathematical expression is a simple text input
  • the error check only occurs once the user attempts to publish - therefore if there is an error, we remain consistent with errors while publishing and display an error message: it reads "Could not save due to an error. Malformed input: syntax error"
  • In addition to the error message we show the error state in the input field
  • On the display side, we show whatever the tool math extensions gives us. On desktop it looks like this:
    Screenshot 2026-01-28 at 08.31.05.png (250×1 px, 32 KB)

Acceptance Criteria:

  • The input field for mathematical expression is a simple text input.
  • The math equations are only supported in LTR (for now)
  • In case the math equation is too long, it should be truncated (overflow-x) with a gradient like the Musical notation.
  • The valid math equation will be placed as it is from the server rendering.

Event Timeline

Alice.moutinho renamed this task from Simple text input (string) with different output to Simple text input (string) with value specific output.Sep 26 2025, 12:50 PM
karapayneWMDE renamed this task from Simple text input (string) with value specific output to [MEX] 4.1.1 - Simple text input (string) with value specific output.Oct 15 2025, 9:19 AM
Alice.moutinho renamed this task from [MEX] 4.1.1 - Simple text input (string) with value specific output to [MEX] 4.1.1 - Mathematical expression: Simple text input (string) with value specific output.Oct 16 2025, 11:46 AM
Alice.moutinho removed Alice.moutinho as the assignee of this task.
Alice.moutinho updated the task description. (Show Details)
karapayneWMDE renamed this task from [MEX] 4.1.1 - Mathematical expression: Simple text input (string) with value specific output to [MEX] M4.1.1 - Mathematical expression: Simple text input (string) with value specific output.Nov 24 2025, 8:35 AM

Change #1235065 had a related patch set uploaded (by Mahmoud-abdelsattar; author: Mahmoud-abdelsattar):

[mediawiki/extensions/Wikibase@master] T405730: Mathematical expression: Simple text input

https://gerrit.wikimedia.org/r/1235065

🔄 Development Handover Summary

NOTE: 🟢 Move from "In Development" > "Ready for Review"

📋 Overview

This work adds support for Math expressions in the Wikibase UI 2025 editing interface. Users can now edit mathematical formulas on items that have math-type properties. The implementation includes:

  • Rendering math expressions in both read and edit modes.
  • Displaying user-friendly error messages when invalid syntax is submitted.
  • Visual error state on input fields when validation fails.
  • Proper error handling that captures detailed API error messages.

✅ Work Completed

  • Added math datatype to StringValueStrategy for editing support.
  • Implemented math value rendering using MediaWiki's Math extension.
  • Added [extractErrorMessage](repo/resources/wikibase.wbui2025/utils.js) utility function to parse API errors and show user-friendly messages.
  • Implemented hasValidationError state in snak stores to show input error styling.
  • Fixed save button re-enablement after validation errors.
  • Implemented Jest tests with proper testing logic.

Architecture/Design Decisions:

  • Reused StringValueStrategy for math: Math expressions use the same strategy as strings since both are text-based inputs.
  • hasValidationError in snak store: Error state is stored per-snak to allow targeted error styling.
  • Extract error from API response: Uses error.errors[0]['*'] for user-friendly message with wikibase-error-save-generic prefix.

Dependencies:

  • Uses existing wikibase-error-save-generic translation key from lib/i18n/en.json.
  • Uses Codex cdx-text-input--status-error class for input error styling.

🧪 Testing/Technical Status

Completed:

  • Manual testing performed for math expression editing
  • Manual testing performed for validation error display
  • Manual testing performed for error state on input
  • JavaScript syntax validation passing

Manual Testing Performed:

  • Created/edited math statements with valid LaTeX - works correctly.
  • Submitted invalid LaTeX syntax - error message displays with specific error.
  • Corrected invalid value after error - save button re-enables.
  • Error styling appears on input field when validation fails.
  • Error styling clears when user starts typing.

Known Test Limitations:

  • No Cypress E2E tests were added.

🔗 Related Resources

Related Gerrit patch:
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/1235065


Handover Date: 02-02-2026
Last Updated By: Mahmoud
Status: Ready for Peer Review

karapayneWMDE renamed this task from [MEX] M4.1.1 - Mathematical expression: Simple text input (string) with value specific output to [MEX] M4.1.5 - Mathematical expression: Simple text input (string) with value specific output.Feb 10 2026, 4:26 PM

Change #1235065 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] T405730: Mathematical expression: Simple text input

https://gerrit.wikimedia.org/r/1235065

Change #1240604 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Add missing statementId property to snakValue spec

https://gerrit.wikimedia.org/r/1240604

Change #1240604 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Add missing statementId property to snakValue spec

https://gerrit.wikimedia.org/r/1240604