Skip to content

Error in solution for "2.3. Add a dashboard item" #1112

Description

@ronikarjalainen

Hi,

The assignment has us create a dashboard item, with optional size prop, that should default to 1. That should be reflected in the size of the displayed element.

This is the solution provided: dashboard_item.js
And it's used like this in the Dashboard: dashboard.xml

However, if the prop isn't provided, this is what appears:
<div class="card m-2 border-dark" style="width: NaNrem;"><div class="card-body">some content </div></div>

It looks like I'm not imagining this since it appears to be included in the relevant screenshot as well:

https://www.odoo.com/documentation/18.0/_images/dashboard_item.png

If the elements containing "some content" truly were 18rem wide, they'd be about half of what the element containing "I love milk" is.

I solved it myself by adding setup() in DashboardItem:
setup() { this.size = 1; if(this.props.size && this.props.size > 0) { this.size = this.props.size; } }

And adjusting line 5 in dashboard_item.xml:
<div class="card d-inline-block m-2" t-attf-style="width: {{18*size}}rem;">

Is there a way to make it work with the default value for the size prop though?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions