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

chore(menu): support delivering submenus via directives #4226

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

Westbrook
Copy link
Contributor

Description

Expand use of slottable-request based laziness to support submenus.

How has this been tested?

  • Test case 1
    1. Go here
    2. See that the submenu can be activated with the mouse or the keyboard
    3. When using the keyboard confirm that the "visible focus" returns to the submenu host, not the first menu item in the parent menu

Types of changes

  • New feature (non-breaking change which adds functionality)

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

@Westbrook Westbrook requested a review from a team March 27, 2024 17:56
Copy link

github-actions bot commented Mar 27, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.95 0.98 0.95
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 228.614 kB 217.158 kB 🏆 217.617 kB
Scripts 60.31 kB 54.437 kB 🏆 54.705 kB
Stylesheet 35.71 kB 30.749 kB 🏆 30.928 kB
Document 5.882 kB 5.26 kB 🏆 5.272 kB
Third Party 126.712 kB 126.712 kB 126.712 kB

Request Count

Category Latest Main Branch
Total 43 43 43
Scripts 35 35 35
Stylesheet 5 5 5
Document 1 1 1
Third Party 2 2 2

Copy link

github-actions bot commented Mar 27, 2024

Tachometer results

Chrome

action-bar permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 483 kB 74.07ms - 77.58ms - unsure 🔍
-4% - +3%
-2.75ms - +2.22ms
branch 474 kB 74.33ms - 77.85ms unsure 🔍
-3% - +4%
-2.22ms - +2.75ms
-

action-menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 645 kB 158.97ms - 163.05ms - unsure 🔍
-3% - +1%
-5.22ms - +1.58ms
branch 637 kB 160.11ms - 165.55ms unsure 🔍
-1% - +3%
-1.58ms - +5.22ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 602 kB 87.98ms - 90.13ms - unsure 🔍
-1% - +2%
-0.97ms - +2.02ms
branch 594 kB 87.49ms - 89.57ms unsure 🔍
-2% - +1%
-2.02ms - +0.97ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 602 kB 86.22ms - 88.13ms - unsure 🔍
-1% - +2%
-0.83ms - +1.89ms
branch 593 kB 85.68ms - 87.62ms unsure 🔍
-2% - +1%
-1.89ms - +0.83ms
-

test-open-close-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 785 kB 1871.84ms - 1875.68ms - unsure 🔍
-0% - +0%
-2.61ms - +1.99ms
branch 777 kB 1872.80ms - 1875.33ms unsure 🔍
-0% - +0%
-1.99ms - +2.61ms
-

test-open-close permalink

Version Bytes Avg Time vs remote vs branch
npm latest 783 kB 1857.41ms - 1860.54ms - unsure 🔍
-0% - +0%
-2.71ms - +1.21ms
branch 775 kB 1858.54ms - 1860.90ms unsure 🔍
-0% - +0%
-1.21ms - +2.71ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 705 kB 35.76ms - 36.37ms - faster ✔
1% - 3%
0.23ms - 0.97ms
branch 697 kB 36.45ms - 36.87ms slower ❌
1% - 3%
0.23ms - 0.97ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 705 kB 376.66ms - 382.56ms - unsure 🔍
-2% - +0%
-7.43ms - +1.21ms
branch 697 kB 379.57ms - 385.87ms unsure 🔍
-0% - +2%
-1.21ms - +7.43ms
-

menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 473 kB 202.05ms - 205.94ms - unsure 🔍
-3% - +0%
-5.54ms - +0.18ms
branch 466 kB 204.57ms - 208.77ms unsure 🔍
-0% - +3%
-0.18ms - +5.54ms
-

overlay permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 676 kB 459.57ms - 463.47ms - unsure 🔍
-1% - +1%
-3.86ms - +2.49ms
branch 666 kB 459.69ms - 464.71ms unsure 🔍
-1% - +1%
-2.49ms - +3.86ms
-

directive-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 785 kB 34.80ms - 35.31ms - unsure 🔍
-0% - +2%
-0.09ms - +0.67ms
branch 775 kB 34.48ms - 35.05ms unsure 🔍
-2% - +0%
-0.67ms - +0.09ms
-

element-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 756 kB 340.46ms - 345.42ms - unsure 🔍
-1% - +0%
-4.46ms - +1.66ms
branch 748 kB 342.54ms - 346.13ms unsure 🔍
-0% - +1%
-1.66ms - +4.46ms
-

lazy-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 557 kB 52.80ms - 53.84ms - unsure 🔍
-0% - +2%
-0.22ms - +1.16ms
branch 549 kB 52.40ms - 53.31ms unsure 🔍
-2% - +0%
-1.16ms - +0.22ms
-

picker permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 511 kB 554.57ms - 565.12ms - unsure 🔍
-1% - +1%
-5.35ms - +8.36ms
branch 503 kB 553.96ms - 562.72ms unsure 🔍
-1% - +1%
-8.36ms - +5.35ms
-

popover permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 382 kB 21.14ms - 21.43ms - unsure 🔍
-1% - +1%
-0.12ms - +0.22ms
branch 373 kB 21.14ms - 21.33ms unsure 🔍
-1% - +1%
-0.22ms - +0.12ms
-

split-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 718 kB 1855.50ms - 1858.72ms - unsure 🔍
-0% - +0%
-3.54ms - +1.01ms
branch 710 kB 1856.77ms - 1859.98ms unsure 🔍
-0% - +0%
-1.01ms - +3.54ms
-

tooltip permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 547 kB 43.88ms - 44.63ms - unsure 🔍
-1% - +2%
-0.44ms - +1.07ms
branch 539 kB 43.28ms - 44.59ms unsure 🔍
-2% - +1%
-1.07ms - +0.44ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 645 kB 34.91ms - 35.36ms - unsure 🔍
-0% - +2%
-0.15ms - +0.59ms
branch 636 kB 34.62ms - 35.21ms unsure 🔍
-2% - +0%
-0.59ms - +0.15ms
-

test-element permalink

Version Bytes Avg Time vs remote vs branch
npm latest 650 kB 62.37ms - 63.45ms - slower ❌
1% - 3%
0.50ms - 1.90ms
branch 642 kB 61.27ms - 62.15ms faster ✔
1% - 3%
0.50ms - 1.90ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 628 kB 52.52ms - 54.04ms - slower ❌
1% - 4%
0.32ms - 2.11ms
branch 619 kB 51.60ms - 52.54ms faster ✔
1% - 4%
0.32ms - 2.11ms
-

truncated permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 523 kB 56.30ms - 57.35ms - unsure 🔍
-1% - +2%
-0.35ms - +1.04ms
branch 515 kB 56.03ms - 56.94ms unsure 🔍
-2% - +1%
-1.04ms - +0.35ms
-
Firefox

action-bar permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 483 kB 135.97ms - 144.39ms - unsure 🔍
-5% - +3%
-6.62ms - +3.94ms
branch 474 kB 138.34ms - 144.70ms unsure 🔍
-3% - +5%
-3.94ms - +6.62ms
-

action-menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 645 kB 299.62ms - 306.58ms - faster ✔
6% - 8%
18.11ms - 27.65ms
branch 637 kB 322.71ms - 329.25ms slower ❌
6% - 9%
18.11ms - 27.65ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 602 kB 152.61ms - 155.55ms - unsure 🔍
-1% - +1%
-1.91ms - +1.91ms
branch 594 kB 152.86ms - 155.30ms unsure 🔍
-1% - +1%
-1.91ms - +1.91ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 602 kB 172.41ms - 178.03ms - slower ❌
6% - 11%
9.15ms - 16.93ms
branch 593 kB 159.49ms - 164.87ms faster ✔
5% - 10%
9.15ms - 16.93ms
-

test-open-close-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 785 kB 1471.69ms - 1477.47ms - slower ❌
2% - 3%
29.25ms - 36.31ms
branch 777 kB 1439.78ms - 1443.82ms faster ✔
2% - 2%
29.25ms - 36.31ms
-

test-open-close permalink

Version Bytes Avg Time vs remote vs branch
npm latest 783 kB 1461.93ms - 1466.27ms - unsure 🔍
-0% - +0%
-4.15ms - +2.59ms
branch 775 kB 1462.31ms - 1467.45ms unsure 🔍
-0% - +0%
-2.59ms - +4.15ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 705 kB 61.80ms - 66.48ms - slower ❌
5% - 14%
3.20ms - 7.92ms
branch 697 kB 58.29ms - 58.87ms faster ✔
5% - 12%
3.20ms - 7.92ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 705 kB 697.65ms - 715.91ms - slower ❌
2% - 6%
14.82ms - 41.78ms
branch 697 kB 668.57ms - 688.39ms faster ✔
2% - 6%
14.82ms - 41.78ms
-

menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 473 kB 415.33ms - 425.83ms - unsure 🔍
-2% - +2%
-9.75ms - +7.79ms
branch 466 kB 414.54ms - 428.58ms unsure 🔍
-2% - +2%
-7.79ms - +9.75ms
-

overlay permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 763 kB 641.02ms - 647.70ms - slower ❌
2% - 4%
13.73ms - 23.35ms
branch 755 kB 622.36ms - 629.28ms faster ✔
2% - 4%
13.73ms - 23.35ms
-

directive-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 767 kB 66.92ms - 69.56ms - slower ❌
2% - 7%
1.51ms - 4.61ms
branch 759 kB 64.37ms - 65.99ms faster ✔
2% - 7%
1.51ms - 4.61ms
-

element-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 756 kB 600.12ms - 608.76ms - slower ❌
2% - 4%
12.94ms - 23.14ms
branch 748 kB 583.69ms - 589.11ms faster ✔
2% - 4%
12.94ms - 23.14ms
-

lazy-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 557 kB 109.67ms - 112.29ms - slower ❌
10% - 12%
9.65ms - 12.39ms
branch 549 kB 99.55ms - 100.37ms faster ✔
9% - 11%
9.65ms - 12.39ms
-

picker permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 511 kB 1008.56ms - 1035.44ms - unsure 🔍
-0% - +3%
-1.07ms - +28.23ms
branch 503 kB 1002.58ms - 1014.26ms unsure 🔍
-3% - +0%
-28.23ms - +1.07ms
-

popover permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 382 kB 39.49ms - 43.71ms - unsure 🔍
-5% - +7%
-2.14ms - +3.02ms
branch 373 kB 39.68ms - 42.64ms unsure 🔍
-7% - +5%
-3.02ms - +2.14ms
-

split-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 718 kB 1429.48ms - 1433.32ms - unsure 🔍
+0% - +0%
+0.22ms - +5.82ms
branch 710 kB 1426.35ms - 1430.41ms unsure 🔍
-0% - -0%
-5.82ms - -0.22ms
-

tooltip permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 650 kB 92.26ms - 96.90ms - slower ❌
3% - 10%
2.90ms - 8.66ms
branch 642 kB 87.10ms - 90.50ms faster ✔
3% - 9%
2.90ms - 8.66ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 631 kB 66.52ms - 67.96ms - faster ✔
20% - 26%
16.73ms - 23.43ms
branch 622 kB 84.05ms - 90.59ms slower ❌
25% - 35%
16.73ms - 23.43ms
-

test-element permalink

Version Bytes Avg Time vs remote vs branch
npm latest 650 kB 129.62ms - 133.78ms - unsure 🔍
-4% - +2%
-5.51ms - +2.43ms
branch 642 kB 129.86ms - 136.62ms unsure 🔍
-2% - +4%
-2.43ms - +5.51ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 628 kB 107.18ms - 111.14ms - unsure 🔍
-3% - +2%
-3.20ms - +2.32ms
branch 619 kB 107.67ms - 111.53ms unsure 🔍
-2% - +3%
-2.32ms - +3.20ms
-

truncated permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 523 kB 98.51ms - 104.29ms - unsure 🔍
-5% - +3%
-4.85ms - +3.41ms
branch 515 kB 99.16ms - 105.08ms unsure 🔍
-3% - +5%
-3.41ms - +4.85ms
-

@najikahalsema
Copy link
Collaborator

The submenu flickers a little when I open it with my mouse. 🤔 Does that happen for you? I'm assuming "no"...

Screen.Recording.2024-03-27.at.11.49.08.mov

Comment on lines +543 to +545
if (this.lastRequestSlottableState === this.open) {
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch on the stutter, @najikahalsema, we should use broken browsers more often? This will prevent duplicate slottable-request events from being dispatched with the same data, which appears to be what was causing what you captured, even if it was really difficult to run into normally.

@@ -39,6 +39,7 @@ import checkmarkStyles from '@spectrum-web-components/icon/src/spectrum-icon-che
import type { Menu } from './Menu.js';
import { MutationController } from '@lit-labs/observers/mutation-controller.js';
import type { Overlay } from '@spectrum-web-components/overlay';
import { SlottableRequestEvent } from '@spectrum-web-components/overlay/src/slottable-request-event.js';
Copy link
Contributor

@Rajdeepc Rajdeepc Mar 28, 2024

Choose a reason for hiding this comment

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

I am not sure whether we have expanded the readme to include this usage but we can definately add some context now on this for the consumers in a good document on how and when to use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This unlocks the last bit of scope for the initial test interaction with the PS team. Once that test cycle is complete, the last piece of confirmation before documentation/"official release" will be confirming how the directives work in partnership with requests for content in slots other than the default slot AND THEN I will start writing documentation with all available speed. One part of that documentation will also be internal outlining path for future use of this form of "enhancement testing process".

flatten: true,
});
this.hasSubmenu = !!assignedElements.length;
})[0] as HTMLElement;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep a null pointer check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The return value for assignedElements() is always an array, even if it's empty, which means that accessing the 0 index will either get an Element or undefined, which are the two values that we expect here. Is there an alternative form of protection that you'd like to see a null pointer check guard us from?

@Westbrook Westbrook merged commit a1af71c into main Mar 28, 2024
49 checks passed
@Westbrook Westbrook deleted the submenu-directive branch March 28, 2024 20:40
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.

None yet

4 participants