Skip to content

Buttons: Remove unnecessary Title, AriaLabel properties#9098

Merged
henon merged 8 commits intoMudBlazor:devfrom
danielchalmers:obsolete-attribute-properties
Jun 9, 2024
Merged

Buttons: Remove unnecessary Title, AriaLabel properties#9098
henon merged 8 commits intoMudBlazor:devfrom
danielchalmers:obsolete-attribute-properties

Conversation

@danielchalmers
Copy link
Member

@danielchalmers danielchalmers commented Jun 1, 2024

Description

The Title property originated to supply a title attribute to the internal MudIcon. This is a valid use because it wasn't reachable otherwise. Later in #4280 it was changed to apply title directly to the button so the tooltip would appear if hovering over padding and not just the icon, but that rendered the property obsolete because internally both of these are the same:

<MudButton Title="Hello"/>
<MudButton title="Hello"/>

In #8630 I expanded the Title property to MudBaseButton without questioning the need for it in the first place, but I can't see any reason to have a dedicated property at this point.

It has some minor value in the MudToggleIconButton but are we planning on adding every conceivable attribute for convenience? I added ToggledUserAttributes as a flexible alternative which will cut down on the number of properties.

How Has This Been Tested?

 
unit

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)
  • Removes MudBaseButton.Title
  • Removes MudToggleIconButton.Title
  • Removes MudToggleIconButton.ToggledTitle
  • Removes MudToggleIconButton.AriaLabel
  • Removes MudToggleIconButton.ToggledAriaLabel
  • Adds docs

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added the breaking change This change will require consumer code updates label Jun 1, 2024
@danielchalmers
Copy link
Member Author

danielchalmers commented Jun 1, 2024

@henon @ScarletKuro thoughts on deleting these redundant properties for v7 and keeping a philosophy of only adding properties for attributes when it has concrete values?

@danielchalmers danielchalmers changed the title Buttons: Remove unnecessary attribute properties Buttons: Remove unnecessary Title, AriaLabel properties Jun 2, 2024
@henon
Copy link
Contributor

henon commented Jun 2, 2024

If the title attribute makes sense on MudButton then it would be best to have a Title parameter. This would be consistent with @onclick and OnClick. The advantage is that it is available for Intellisense and in the API Documentation and our users don't have to be html gurus to know that this functionality is available. I myself didn't even know about the title attribute of the button tag.

<summary>
The Title parameter adds a tooltip with title text to the button.
Hovering the mouse over the button will display the tooltip.
</summary>

If Title doesn't make sense for all descendents of MudBaseButton we'll have to pull it down again into those where it makes sense.

@henon
Copy link
Contributor

henon commented Jun 2, 2024

Of course this is always also a performance question. Every parameter adds a bit of overhead. So I guess the question is what is more important, performance or usability. Hard to say. We may be prematurely optimizing. There are usually only a handfull of buttons on every page and I'd say this is the most likely use-case.

On the other hand - and I am arguing against what I wrote above - we could just link to the W3C button page in the docs and tell users that all attributes added to MudButton are forwarded to the internal <button/> tag. Maybe that would be the best solution.

@MBNSoftware
Copy link

Usually only a handfull of buttons...

... a bit of overhead...

That could mean not that much overhead at the end. So usability (and consistency) may win against perfomance in this case ?

@danielchalmers
Copy link
Member Author

If the title attribute makes sense on MudButton then it would be best to have a Title parameter. This would be consistent with @onclick and OnClick. The advantage is that it is available for Intellisense and in the API Documentation and our users don't have to be html gurus to know that this functionality is available. I myself didn't even know about the title attribute of the button tag.

@henon The issue is that

  1. The title attribute makes sense on a lot of components, not just button
  2. There are other attributes that make sense on the button as well (Random examples: role, type, value, aria-label, aria-labelledby, aria-busy, accesskey, translate, etc)

On the other hand - and I am arguing against what I wrote above - we could just link to the W3C button page in the docs and tell users that all attributes added to MudButton are forwarded to the internal tag. Maybe that would be the best solution.

I'd agree with that in general because there are so many possible attributes for every component that it would be a never-ending venture to add them all. I don't know if it's our job to teach users about common attributes.

@danielchalmers
Copy link
Member Author

What would the link in the docs look like? We could add it directly to the class XML docs now that #8903 will be added

you can only have one property with that
@codecov
Copy link

codecov bot commented Jun 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.63%. Comparing base (28bc599) to head (da90520).
Report is 261 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #9098      +/-   ##
==========================================
+ Coverage   89.82%   90.63%   +0.80%     
==========================================
  Files         412      399      -13     
  Lines       11878    12494     +616     
  Branches     2364     2431      +67     
==========================================
+ Hits        10670    11324     +654     
+ Misses        681      626      -55     
- Partials      527      544      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danielchalmers
Copy link
Member Author

Added some docs to remind people they have more options for attributes; What do you think? @henon @jperson2000

@danielchalmers danielchalmers marked this pull request as ready for review June 3, 2024 01:11
@danielchalmers
Copy link
Member Author

@henon @ScarletKuro Does my implementation of ToggledUserAttributes make sense when the regular UserAttributes is capturing but ToggledUserAttributes is not? I'm not really sure the right way of handling this and whether this property makes sense in the first place. It could alternatively be applied on top of UserAttributes instead of replacing it.

@henon
Copy link
Contributor

henon commented Jun 3, 2024

Added some docs to remind people they have more options for attributes; What do you think? @henon @jperson2000

I was more thinking of the button page in our docs. The XML summary of MudButton is not the main info source for our users.

@danielchalmers
Copy link
Member Author

I was more thinking of the button page in our docs. The XML summary of MudButton is not the main info source for our users.

#8903 shows the summaries on the docs page, is that enough? @henon

image

@henon
Copy link
Contributor

henon commented Jun 4, 2024

OK, I guess that will be enough

Copy link
Contributor

@henon henon left a comment

Choose a reason for hiding this comment

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

I don't know about the ToggledAttributes. Do we really need this just for "title" and "aria-label" which we just decided to remove as parameters?

@henon henon requested a review from ScarletKuro June 4, 2024 19:13
@henon henon merged commit 92d2809 into MudBlazor:dev Jun 9, 2024
@henon
Copy link
Contributor

henon commented Jun 9, 2024

Thanks Daniel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change This change will require consumer code updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants