Conversation
📝 WalkthroughWalkthroughRemoved Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@libs/zard/src/lib/shared/components/menu/menu.directive.ts`:
- Line 111: Replace the plain focus() call in the menu directive with a
non-scrolling focus invocation to match the PR intent: change the existing
element.focus() call (in the menu directive where the element is focused after
hover/open) to element.focus({ preventScroll: true }) so the focus action does
not cause page scrolling; update the call in the MenuDirective (where the focus
is currently performed) accordingly.
4053d1e to
b5ef775
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
libs/zard/src/lib/shared/components/menu/menu.directive.ts (2)
48-48: 🧹 Nitpick | 🔵 TrivialType the
ElementRefto avoid implicitany.
inject(ElementRef)gives youElementRef<any>. Since you're calling.focus()and.contains()onnativeElement, type it explicitly for proper type safety.Proposed fix
- private readonly elementRef = inject(ElementRef); + private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);As per coding guidelines: "Use TypeScript for all project files with proper typing and avoid
anytype."
106-115:⚠️ Potential issue | 🟠 MajorAdd
tabindex: '0'to the host metadata to enable focus functionality.The
element.focus({ preventScroll: true })call on line 111 won't execute effectively without an explicittabindex. The host metadata declaresrole: 'button'but lackstabindex, meaning[z-menu]applied to non-natively-focusable elements (e.g.,<div>,<span>) will silently ignore thefocus()call. The siblingz-context-menuandz-menu-contentdirectives already settabindex: '0'in this codebase; align this directive for consistency:Required fix
host: { role: 'button', + '[attr.tabindex]': "'0'", '[attr.aria-haspopup]': "'menu'",
b5ef775 to
7a9b926
Compare
What was done? 📝
When we have more menus on page clicking on item gives focus to element. After we hover on another menu page wants to scroll to focused element. With this fix menu gets focus on hover so previous menu looses it and therefor page will not need to scroll at all.
Screenshots or GIFs 📸
|-----Figma-----|
|-----Implementation-----|
Link to Issue 🔗
closes #418
Type of change 🏗
Breaking change 🚨
Checklist 🧐
Summary by CodeRabbit
Bug Fixes
Accessibility