Skip to content

fix: render Work Certified % card without jQuery selector error - #16

Merged
skibanga merged 1 commit into
masterfrom
fix/billed-percent-card
Oct 12, 2026
Merged

skibanga merged 1 commit into
masterfrom
fix/billed-percent-card

Conversation

@skibanga

Copy link
Copy Markdown
Collaborator

Problem

The Work Certified % of Contracts card on the Construction MS workspace did not render. The browser console showed:

Uncaught (in promise) Error: Syntax error, unrecognized expression: 0.55%
    at NumberCardWidget.set_formatted_number (number_card_widget.js:253)

The custom card method returned its value as text ("0.55%", fieldtype Data). Frappe's number card passes the formatted value to jQuery as $(formatted_number). Plain text is read as a CSS selector, and 0.55% is not a valid selector. Number fieldtypes come back wrapped in HTML, so they are not affected.

Fix

billed_percent now returns a number, with fieldtype: Percent and precision: 2. The card already has show_full_number set, so small values such as 0.55% are not shortened to 1%.

Testing

On a local v15 site, billed_percent() returns {'value': 0.5498, 'fieldtype': 'Percent', 'precision': 2, ...}. Frappe's Percent formatter uses the given precision and wraps the result in HTML, so the card shows 0.55% without the console error.

🤖 Generated with Claude Code

The card returned its value as text ("0.55%"). Frappe passes the
formatted value to jQuery, which read the plain text as a selector and
threw "unrecognized expression". Return a numeric Percent with
precision 2 instead; show_full_number keeps small values from being
rounded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skibanga
skibanga merged commit 9aa7782 into master Oct 12, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant