jwstegemann / fritz2

Easily build reactive web-apps in Kotlin based on flows and coroutines.
https://www.fritz2.dev
MIT License
627 stars 25 forks source link

Rethink Default ARIA Roles for Headless DataCollection #827

Open Lysander opened 6 months ago

Lysander commented 6 months ago

Currently some default ARIA-Roles are set inside the headless datatable bricks:

This design has different problems: The ARIA Role for the main collection type might be suited at the wrong DOM-level: If you want to create some Datatable alike component, dataCollectionItems is located beneath some potential table-Tag. But the latter defines implicitly the ARIA role. In order to achieve this, you are forced to write some "reset" alike statement:

// inside some render-Code:
dataCollection(
        tag = RenderContext::table // this already defines the `table` role!
    ) {
    dataCollectionItems(...) {
        attr("role", "")  // reset default headless role one level beneath and without any obvious relation to the tag above!
        items.renderEach(...) { item ->
            dataCollectionItem(item, tag = RenderContext::tr) {
                attr("role", "") // same again, besides this is the correct DOM level
            }
    }
}

This arises the fundamental questions: