Blocks display HTML twice when used together with choice

Hello,

I need some more information in my span annotation task and therefore worked with blocks:

    blocks = [
        {"view_id": "html"},
        {
            "view_id": "choice",
            "text": "Relevance correct?",
            "options": [
                {"id": 1, "text": "True"},
                {"id": 0, "text": "False"},
            ],
        },
        {"view_id": "spans_manual"},
    ]

I expect the HTML to appear once. However as you can see in the screenshot it appears twice.

Best,

Maximilian

I just found in the Forum a way to disable the HTML by setting html=None. However, now the text of the my span annotation is displayed instead of the string that I passed…

Hi @MaximilianHess! Glad you got this part working. If your data contains "text", "tokens" and "spans", the spans_manual block should render existing annotations accordingly. Can you share an example of the JSON you're passing in?

The span annotation part is displayed correctly. What gives me troubles is that the choice part of blocks takes the text of the json instead of the string that I passed in the defintion of blocks (see below). That means I have the text two times now. Once in the span annotation and once in the choice annotation.

    blocks = [
        {"view_id": "html"},
        {
            "view_id": "choice",
            "text": "Relevance correct?",
            "html": None,
            "options": [
                {"id": 1, "text": "True"},
                {"id": 0, "text": "False"},
            ],
        },
        {"view_id": "spans_manual"},
    ]

Here a Screenshot of an example I can share:

Hi @MaximilianHess,

What is happening is that the text attribute on the task takes priority over the text attribute defined in the choice block. This is why you see it rendered twice in the UI. To avoid these kind of conflicts we usually recommend defining the interface via pages UI where each component or block is rendered and handled in isolation from other blocks - you can see the docs on pages here

In your case, however, even a simpler workaround could be more practical: instead of defining "Relevance correct" as a text attribute of the choice block, you can define it as a static html block right above the choice block:

 blocks = [
        {"view_id": "html"},
        {"view_id": "html", "html": "Relevance correct"},
        {
            "view_id": "choice",
            "html": None,
            "text": None,
            "options": [
                {"id": 1, "text": "True"},
                {"id": 0, "text": "False"},
            ],
        },
        {"view_id": "spans_manual"},
    ]

The first html block will be populated by whatever HTML is provided by the task and the second html block will be static and the same for all tasks, effectively working as a "header" for the following options of the choice block.

Thank you! That solved my problem! :).