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

fix(menu): prevent sp-menu-item text-align cascading #4868

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

mizgaionutalexandru
Copy link
Contributor

@mizgaionutalexandru mizgaionutalexandru commented Oct 28, 2024

Description

Previous to the Overlay V2, the text-align property of action-menu, or similar components, did not cascade into the sp-menu-items. This PR brings back that behavior by setting the text-align: initial on sp-menu-item.

PS: This is the same behavior as in React Spectrum. As per Spectrum guidelines I haven't yet seen a use-case for other types of aligment. If they are needed, we can provide a --mod-* type css variable.
There is also an on-going discussion on a spectrum-css issue but this missalignment in behavior comes from the SWC's approach to Overlay so I think this is a good place to fix.

Related issue(s)

  • N/A

Motivation and context

Fixes the text-align cascading into the overlay menu-items.

How has this been tested?

  • Test case 1

    1. Open ActionMenu Storybook
    2. Place a text-align: center on a parent of the ActionMenu (e.g. sp-theme)
    3. Click the ActionMenu
    4. Observe that the text inside the menu-items is centered
  • Did it pass in Desktop?

  • Did it pass in Mobile?

  • Did it pass in iPad?

Screenshots (if appropriate)

Without the change:
without the fix

After the change:
with the fix

Types 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 change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

github-actions bot commented Oct 28, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.99 0.99 0.99
Accessibility 1 1 1
Best Practices 1 1 1
SEO 1 0.92 0.92
PWA 1 1 1
What is this?

Lighthouse scores comparing the documentation site built from the PR ("Branch") to that of the production documentation site ("Latest") and the build currently on main ("Main"). Higher scores are better, but note that the SEO scores on Netlify URLs are artifically constrained to 0.92.

Transfer Size

Category Latest Main Branch
Total 251.981 kB 236.77 kB 236.501 kB 🏆
Scripts 62.007 kB 54.113 kB 🏆 54.227 kB
Stylesheet 53.976 kB 48.03 kB 47.81 kB 🏆
Document 6.194 kB 5.432 kB 🏆 5.434 kB
Font 126.892 kB 126.748 kB 126.638 kB 🏆

Request Count

Category Latest Main Branch
Total 52 52 52
Scripts 41 41 41
Stylesheet 5 5 5
Document 1 1 1
Font 2 2 2

@coveralls
Copy link
Collaborator

coveralls commented Oct 28, 2024

Pull Request Test Coverage Report for Build 11631190725

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.189%

Totals Coverage Status
Change from base Build 11617424981: 0.0%
Covered Lines: 32313
Relevant Lines: 32735

💛 - Coveralls

@mizgaionutalexandru mizgaionutalexandru marked this pull request as ready for review October 28, 2024 15:17
@mizgaionutalexandru mizgaionutalexandru requested a review from a team as a code owner October 28, 2024 15:17
Copy link

github-actions bot commented Oct 28, 2024

Tachometer results

Chrome

action-menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 960 kB 140.17ms - 143.51ms - faster ✔
4% - 7%
6.70ms - 11.27ms
branch 917 kB 149.27ms - 152.39ms slower ❌
5% - 8%
6.70ms - 11.27ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 917 kB 70.00ms - 70.86ms - faster ✔
7% - 9%
5.14ms - 6.86ms
branch 874 kB 75.69ms - 77.17ms slower ❌
7% - 10%
5.14ms - 6.86ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 916 kB 68.55ms - 70.51ms - faster ✔
6% - 10%
4.62ms - 7.38ms
branch 873 kB 74.56ms - 76.49ms slower ❌
7% - 11%
4.62ms - 7.38ms
-

test-open-close-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 1.09 MB 1874.56ms - 1877.25ms - unsure 🔍
-0% - +0%
-3.00ms - +1.16ms
branch 1.05 MB 1875.24ms - 1878.41ms unsure 🔍
-0% - +0%
-1.16ms - +3.00ms
-

test-open-close permalink

Version Bytes Avg Time vs remote vs branch
npm latest 1.09 MB 1879.08ms - 1882.27ms - unsure 🔍
-0% - +0%
-3.40ms - +1.19ms
branch 1.05 MB 1880.12ms - 1883.43ms unsure 🔍
-0% - +0%
-1.19ms - +3.40ms
-

breadcrumbs permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 979 kB 529.78ms - 534.71ms - faster ✔
1% - 3%
7.16ms - 15.51ms
branch 936 kB 540.21ms - 546.95ms slower ❌
1% - 3%
7.16ms - 15.51ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 1 MB 42.47ms - 43.02ms - faster ✔
1% - 4%
0.53ms - 1.79ms
branch 957 kB 43.34ms - 44.48ms slower ❌
1% - 4%
0.53ms - 1.79ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 1 MB 402.74ms - 408.34ms - faster ✔
2% - 4%
7.23ms - 16.68ms
branch 958 kB 413.69ms - 421.30ms slower ❌
2% - 4%
7.23ms - 16.68ms
-

menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 741 kB 214.29ms - 217.25ms - faster ✔
2% - 4%
3.29ms - 9.27ms
branch 716 kB 219.44ms - 224.64ms slower ❌
2% - 4%
3.29ms - 9.27ms
-

picker permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 817 kB 509.53ms - 518.95ms - faster ✔
2% - 4%
9.95ms - 23.98ms
branch 774 kB 526.01ms - 536.40ms slower ❌
2% - 5%
9.95ms - 23.98ms
-
Firefox

action-menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 960 kB 294.88ms - 301.48ms - faster ✔
14% - 17%
50.05ms - 59.03ms
branch 917 kB 349.68ms - 355.76ms slower ❌
17% - 20%
50.05ms - 59.03ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 917 kB 159.03ms - 164.37ms - unsure 🔍
-1% - +3%
-1.37ms - +4.85ms
branch 874 kB 158.36ms - 161.56ms unsure 🔍
-3% - +1%
-4.85ms - +1.37ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 916 kB 142.54ms - 145.34ms - faster ✔
2% - 4%
2.62ms - 5.90ms
branch 873 kB 147.34ms - 149.06ms slower ❌
2% - 4%
2.62ms - 5.90ms
-

test-open-close-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 1.09 MB 1899.21ms - 1902.95ms - unsure 🔍
-0% - -0%
-9.02ms - -0.22ms
branch 1.05 MB 1901.71ms - 1909.69ms unsure 🔍
+0% - +0%
+0.22ms - +9.02ms
-

test-open-close permalink

Version Bytes Avg Time vs remote vs branch
npm latest 1.09 MB 1905.25ms - 1908.51ms - faster ✔
1% - 1%
9.70ms - 16.82ms
branch 1.05 MB 1916.98ms - 1923.30ms slower ❌
1% - 1%
9.70ms - 16.82ms
-

breadcrumbs permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 979 kB 846.45ms - 863.63ms - faster ✔
1% - 4%
9.65ms - 33.55ms
branch 936 kB 868.33ms - 884.95ms slower ❌
1% - 4%
9.65ms - 33.55ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 1 MB 71.67ms - 75.45ms - unsure 🔍
-5% - +2%
-3.43ms - +1.27ms
branch 957 kB 73.25ms - 76.03ms unsure 🔍
-2% - +5%
-1.27ms - +3.43ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 1 MB 766.08ms - 792.88ms - slower ❌
4% - 9%
32.78ms - 62.70ms
branch 958 kB 725.09ms - 738.39ms faster ✔
4% - 8%
32.78ms - 62.70ms
-

menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 741 kB 403.38ms - 415.66ms - faster ✔
1% - 6%
3.93ms - 25.31ms
branch 716 kB 415.39ms - 432.89ms slower ❌
1% - 6%
3.93ms - 25.31ms
-

picker permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 817 kB 1017.20ms - 1027.68ms - faster ✔
4% - 7%
45.34ms - 81.90ms
branch 774 kB 1068.54ms - 1103.58ms slower ❌
4% - 8%
45.34ms - 81.90ms
-

Copy link
Collaborator

@rubencarvalho rubencarvalho left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Could you look into adding a test for this? Either a new Storybook story or a check for the computed text-align value on the menu item in the scenario where it was breaking would probably work well - just to ensure it doesn’t break again. We can continue discussing with CSS to see if this should eventually be handled on their end, but for now, I’m comfortable having this solution in SWC.

Copy link
Contributor

@TarunAdobe TarunAdobe left a comment

Choose a reason for hiding this comment

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

LGTM!

@rubencarvalho rubencarvalho merged commit 6663820 into main Nov 7, 2024
44 checks passed
@rubencarvalho rubencarvalho deleted the imizga/text-align branch November 7, 2024 17:57
nikkimk pushed a commit that referenced this pull request Nov 19, 2024
* fix(menu): menu item text align initial

* test(menu): added menu-item text-align cascade test

---------

Co-authored-by: Rúben Carvalho <rubcar@sapo.pt>
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.

4 participants