-
Notifications
You must be signed in to change notification settings - Fork 63
Conversation
src/composables/use-focus-on-blur.js
Outdated
const blurredRef = ref(0) | ||
|
||
/** | ||
* @param {number} n | ||
*/ | ||
const scheduleFocus = () => (blurredRef.value += 1) | ||
|
||
return [blurredRef, scheduleFocus] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be turned into a customRef
, but then it would need to use setting to update the value instead of just calling a function that does it for you.
Ehhhh, I think I prefer this slimmer more obvious approach.
0703317
to
9d2cc24
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is such comprehensive work, and the new composables created here will be a great resource for other future components. I wish I had more feedback to offer!
{ case: 'pascalCase', ignore: ['.eslintrc.js', '.*\\.stories\\.js'] }, | ||
// Allow things like `Component.stories.js` and `Component.types.js` | ||
{ | ||
case: 'pascalCase', | ||
ignore: ['.eslintrc.js', '.*\\..*\\.js'], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
@@ -0,0 +1,2 @@ | |||
export const warn = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great addition to the codebase
/** | ||
* This is the only documented emitted event but in reality we pass through `$listeners` | ||
* to the underlying element so anything and everything is emitted. `@keydown` is the | ||
* only one this component overrides and controls (but ultimately still emits). | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ nice!
src/components/VPopover/VPopover.vue
Outdated
:aria-labelledby="labelledBy" | ||
> | ||
<!-- @slot The content of the popover --> | ||
<slot name="content" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this doesn't appear to have a ref or any props passed to the slot, should we make this the default slot to make the component api a little simpler? I think there's also something compelling about having the two explicit slots in the current implementation, so up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! We can do that.
596a214
to
2ecdf6d
Compare
The improvements are really nice, especially the test with two popovers. |
@obulat Do you think you will have time to review this PR this week? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the thoroughness of the implementation! It all works great, and is accessible.
}) | ||
|
||
/** | ||
* @param {Event} event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the Event
type resolve to something useful for you? When I try going to its source in VS Code, it shows me docs from React, and WebStorm goes to sentry/types
... I've ran into such typing problems before, and couldn't find a good solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it shouldn't reference either, it should reference the global Event
type from TypeScript's built in dom.d.ts
: https://github.com/microsoft/TypeScript/blob/main/lib/lib.dom.d.ts#L5034
When I hover over it it shows the description from the global dom types but if I "go to definition" on it in VSCode it does show React and the global dom types. I think the React types get detected because of interface merging and because React declares global types. Luckily they don't modify the Event type in this way. I have no idea what WebStorm pulls types from sentry without an explicit reference to it.
Do you know why I get this warning when I run |
/** | ||
* @typedef Props | ||
* @property {import('./types').Ref<HTMLElement>} popoverRef | ||
* @property {import('./types').ToRefs<import('../components/VPopover/VPopover.types').Props>} popoverPropsRefs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WebStorm shows a warning that VPopover.types
is not found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think WebStorm is using TypeScript to interpret the JSDoc comments.
Yeah, it's because of Nuxt's global component resolution trying to find a component in every single file in the VPopover folder 😞 We could remove it from the global component resolution configuration in |
Co-Authored-By: obulat
Fixes
Fixes #366 by @sarayourfriend
Description
Adds a new
VPopover
component which composes a "trigger" and popover content to create a single, acessible, popover unit.VPopoverContent
can be reused generically if, for any reason (there shouldn't really be any for the most part) a popover is needed with a different trigger mechanism. It implements 95% of the accessibility functionality (onlyaria-haspopup
andaria-expanded
are handled by the parentVPopover
component).Most of the logic for this component is siloed into individual responsibility composables. Most of this logic is copied from Reakit's Dialog and Popover implementations.
VPopoverContent
emits all normaldiv
events.VPopover
emitsopen
andclose
events.Testing Instructions
Run
npm run storybook
and visithttp://localhost:6006/?path=/docs/components-vpopover--default
. Play around with the popover and the various props to make sure it behaves as expected according to the prop descriptions. Unit tests cover almost everything except one edge case that isn't possible to test in JSDom specific to text selection.To test this particular behavior, open the popover and make sure
hideOnClickOutside
is either unset or set totrue
. Then click and drag to select text inside the popover but be sure to finish the drag outside the popover and then release the mouse click. This should not close the popover.This is important because the
click
event is actually happening outside the popover, but in theuseHideOnClickOutside
composable we conditionally hide the popover only when themousedown
event target matches the click target or both are outside the popover. This ensures that the popover doesn't accidentally close if someone is selecting the text inside of it.Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin