Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Rename name to label and use value for label content #475

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

mwcampbell
Copy link
Contributor

I think the new property name and the new use of value on nodes with Role::Label makes sense because:

  • For non-label nodes, their label is now determined by either a direct string in the label property, or the labelled_by relation. The word choice is more consistent.
  • On a label itself, it doesn't make sense to talk about the "label of a label", but "value of a label" does make sense.
  • For labels that have full text support via TextRun nodes, we can now automatically get the label's value from its descendant text runs, rather than having to set the value directly; this follows automatically from the existing support for constructing the value from text in accesskit_consumer::Node::value.

@DataTriny
Copy link
Member

I'm on board with these changes, but I expect the transition to the value property to be painful. Maybe you should split this PR so it has its dedicated entry in the changelog, until we properly document everything?

Also, you're effectively creating a new kind of nodes which are labeled by their value, and I wonder if you should explicitly name them by adding a new method in the consumer crate. I currently have no idea how we'd name this class of nodes, but I don't really like having this check on roles in multiple places.

@mwcampbell
Copy link
Contributor Author

I don't think I understand the benefit of splitting the PR.

@DataTriny
Copy link
Member

It's a subtle change and I wouldn't be surprised if people don't set the value property on labels while migrating, so I'm just trying to see how to make this change more obvious. I think having a dedicated entry in the changelog would make it more noticeable.

@mwcampbell
Copy link
Contributor Author

I don't like the extra churn that splitting the PR would cause in the code itself, just for one extra line in the change log.

@DataTriny
Copy link
Member

Thanks for adding documentation. It doesn't mention that it also applies to Role::Image though. This actually make me question the purpose of this: if I hear "the value of an image", I won't think "text alternative". I'd say that the label property is more appropriate for this role. What was your reasoning for including the image role in this change?

@DataTriny
Copy link
Member

Maybe this is to allow a rich text alternative?

@mwcampbell
Copy link
Contributor Author

You're right about Role::Image. I fixed that, and also addressed your other suggestion.

Copy link
Member

@DataTriny DataTriny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks! Please rebase and merge after that.

@mwcampbell mwcampbell merged commit e0053a5 into main Oct 29, 2024
9 checks passed
@mwcampbell mwcampbell deleted the refactor-label branch October 29, 2024 20:01
@github-actions github-actions bot mentioned this pull request Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants