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
✨ Implement <Listbox />
component
#76
✨ Implement <Listbox />
component
#76
Conversation
<Listbox />
component<Listbox />
component
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'm really excited to see this PR!
I took a first pass through and left some thoughts; there is a lot to review here so it might take me a few passes.
I'm generally going to assume the test implementation is fine and that the tests passing are enough of an indication that they're good-to-go, and will instead focus on the actual add-on source code for review purposes (at least, for now!)
Use `isOpen` as the yielded property name Use a `setter` for this property to ensure state is correct when property is changed externally. Pass `openListbox` and `closeListbox` actions to components.
Use `focus-trap` to manage focus when opening/closing the listbox Use `click-outside` to manage document click events
Now storing the index of each listbox option within the list. This means we avoid an expensive `find` operation when setting the selected option on mouse click or key event.
Sounds good! Thanks for the quick feedback! I've replied to individual comments above. |
I approved the GitHub Actions run so we'll get lint/test results for the PR now. GitHub disables those for first-time contributors (people were abusing the system to mine cryptocurrency 🤦♂️) do you need a contributor to give the OK for CI to run on an individual's first PR! |
660f5cf removes the I had to |
Those crazy cryptokids 😆 I've fixed the lint errors and all tests should be passing now, so please kick-off another CI and see how we are doing 👍 |
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 looking really great! Once we get clarity on the nested conditional I commented on, I am feeling good about merging this PR!
return this._isOpen; | ||
} | ||
|
||
set isOpen(isOpen) { |
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 really like using a "setter" like this; keeps the code for manipulating the value clean, but allows us to perform these side-effects easily as well!
@@ -37,6 +61,12 @@ const DialogState = { | |||
InvisibleUnmounted: 'InvisibleUnmounted', | |||
}; | |||
|
|||
const ListboxState = { | |||
Visible: 'Visible', | |||
InvisibleHidden: 'InvisibleHidden', |
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 see use of this state in tests, I assume that we are just lack of some tests right ? Some assertions don't implement it. Do we have a plan to extend the test suite ?
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.
Maybe would be nice to follow the same approach what @achambers did in dialog ? What I mean is copy test e.g. from react repo and change to todo
example
I am willing to help with them after that and fill gaps.
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.
Ah yes this refers to the alternative "hidden" or "unmount" render strategy, in which React will insert the listbox options into the DOM, but display as hidden.
I think it's safe to push this feature out for now.
b452c35 adds todo
s for these tests.
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 looking for to me! I'm happy to merge it at this point if you're ready @dmcnamara-eng !
🥳 I'm happy. Please merge! |
|
Cheers. Happy days. Let's get this library to |
❤️ |
@dmcnamara-eng how difficult would it be to implement the |
This renders in place instead of absolutely positioned in the body? |
✨ What Changed and Why
This PR is a functionally complete implementation of a
<Listbox />
component based on https://headlessui.dev/react/listboxThings that this PR implements:
Enter
/Space
/ArrowUp
/ArrowDown
/ArrowLeft
/ArrowRight
/PageUp
/PageDown
/Home
/End
/Escape
)aria-expanded
/aria-labelledby
/aria-controls
/aria-haspopup
/aria-active-descendent
) and focus managementThings that this PR does not implement are:
I ported the React component tests for listbox as Ember integration tests. 90 integration tests were ported. Some tests were not ported because they are not applicable to Ember components. A test for transitions was not ported because transitions has not been implemented here yet.
😈 Before
Didn't exist.
😇 After
Closes #69