Skip to content

Case for revised data model: labelled_by #583

@dhardy

Description

@dhardy

Context

If I understand correctly, the labelled_by property allows one Node to be labelled by another, for example a CheckBox with a separate Label widget, both wrapped under some CheckBoxWithLabel widget.

The CheckBox widget doesn't know about the Label (which is external), hence the labelled_by property can only be set by the parent widget (unless the parent explicitly asks the CheckBox to store the identifier of its label, but this is a restrictive and over-complex design).

Motivation: partial tree updates

In the case that a full accessibility tree must be generated the above is fine, but in the case that the CheckBox value changes and the widget tries to update its Node value in the accessibility shadow-tree, it's harder to do this without losing the labelled_by relationship.

Suggestions

I can see a couple of possible solutions here:

  1. Allow access to the prior state of nodes in the accessibility tree: then CheckBox can copy its old value and update it. (This change is quite significant and may be undesirable.)
  2. Move the labelled_by property out of Node to another data structure (e.g. Vec<(NodeId, NodeId)>). Logically a node cannot label more than one other node; this should be enough to allow old (outdated/redundant) labelled_by relationships to be pruned (though it doesn't allow such relationships to be removed; I suspect this is unimportant).
  3. This is a hack, but might not work out too badly in practice: whenever a Node is replaced and the old one has a labelled_by property while the new Node doesn't, copy the property to the new Node. (The side effect is the same as with (2): updates cannot remove a labelled_by relationship.)

Final note

Most Node properties are not affected the same way, though some others may be (possibly radio box groups; I didn't investigate since Kas's widget model doesn't have the necessary data to set this anyway).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions