ts4nfdi / terminology-service-suite

The Terminology Service Suite project is a collection of interactive widgets designed to ease the integration of terminology service functions into third-party applications.
https://ts4nfdi.github.io/terminology-service-suite/comp/latest/
MIT License
16 stars 2 forks source link

TitleWidget shows "No title available" even though default_value is set #112

Closed vera closed 1 month ago

vera commented 4 months ago

Can be reproduced here https://ts4nfdi.github.io/terminology-service-suite/comp/latest/?path=/docs/react_titlewidget--docs (change the IRI to a non-existing one, enter a default_value string)

Also, showing only the loading spinner for several seconds feels slow/unresponsive. Maybe the widget could show the default_value string in addition to the loading spinner while the data is loading?

johannes-darms commented 4 months ago

@jusa3

jusa3 commented 4 months ago

Problem understood and fix in progress. But could you describe a use case that requires a default_value so that I can better understand the use of this parameter? @vera

vera commented 4 months ago

We store the IRI and the label for keywords. I think that in some cases the IRIs are outdated and no longer load, so we would like to display the keyword label as fallback.

Example: https://csh.nfdi4health.de/resource/9 under General information, open the tab "Details". 5/6 keywords don't load and do not show the fallback label.


{
    "keywords": [
        {
            "code": "http://id.nlm.nih.gov/mesh/T045095",
            "label": "Cohort Studies"
        },
        {
            "code": "http://snomed.info/id/363346000",
            "label": "Malignant neoplastic disease (disorder) | SNOMED > 363346000"
        },
        {
            "code": "http://id.nlm.nih.gov/mesh/T000864255",
            "label": "Diet, Food, and Nutrition"
        },
        {
            "code": "https://id.nlm.nih.gov/mesh/T023921.html",
            "label": "Life Style"
        },
        {
            "code": "https://id.nlm.nih.gov/mesh/T008425.html",
            "label": "Chronic Disease"
        }
    ]
}
jusa3 commented 4 months ago

I changed the amount of retries for the query from 3 to 2, that will reduce the loading time. Do you have an idea for showing the loading spinner and default value? @vera Could e.g. look like this:

image

johannes-darms commented 4 months ago

Could we hide the spinner when a default_value is passed? Alternatively we could add a property to configure enable or disable spinner. What do you think?

vera commented 4 months ago

It could be surprising from a user perspective if I am looking at a list of keywords and some of them suddenly change (from the fallback value to the real value) once the loading is complete. So I was also thinking about something like your screenshot @jusa3

Can you somehow tell from the API response that the loading will never succeed (e.g. because the IRI is wrong)? In that case it would be nice to not retry and hide the loading spinner.

jusa3 commented 4 months ago

You mean kind of an IRI check request? I can't think of any. I could conditionally (default value defined or not) use different useQueries and if the default value is defined could set the retry attempts to 0. Then the sudden change from the default value to the real value would be fast but recognisable.

Hiding the spinner or adding a property won't be a problem.

What do you prefer?

vera commented 4 months ago

I thought maybe the query you are already sending in the useQuery maybe returned a failure reason. If it doesn't, I think out of all the options I prefer just showing the default value + loading spinner (default number of retries). I think that's the best overall user experience.

what do you think? @johannes-darms

jusa3 commented 4 months ago

The useQuery error message only says "Network Error".

jusa3 commented 3 months ago

@johannes-darms

johannes-darms commented 3 months ago

I agree with vera.