-
Notifications
You must be signed in to change notification settings - Fork 50
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
Dropdown v6 Update #379
Dropdown v6 Update #379
Conversation
11a1d4a
to
cac0872
Compare
@@ -0,0 +1,132 @@ | |||
- [✔] Styled Systems support | |||
- [✔] WAI-ARIA compliant |
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.
😍
components/check-box/styled.jsx
Outdated
@@ -3,7 +3,7 @@ import { resetStyles } from '../utils'; | |||
import { Box } from '../Box'; | |||
|
|||
export const CheckboxDiv = styled(Box)` | |||
position: absolute; | |||
position: ${({ position }) => position || 'absolute'}; |
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.
??
?
as="a" | ||
ref={ref} | ||
onClick={null} | ||
onKeyDown={null} |
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 seems to be intentional (and I'm not sure on the accessibility rules around this) but I was a little surprised that I couldn't use enter to "click" on the link in the dropdown.
); | ||
const DropdownMenu = deprecateComponent( | ||
DropdownMenuComponent, | ||
depWarning('DropdownMenu', 'Dropdown.Menu'), |
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.
Definitely read this as derpWarning
at first 😂
return handleKeyboardActivate; | ||
} | ||
|
||
export function useKeyboardNavigate(onCloseMenu, onKeyboardNav) { |
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.
Fancy!
@@ -185,8 +185,8 @@ colors.select = { | |||
|
|||
colors.dropdown = { | |||
background: colors.white, | |||
backgroundHover: colors.gray4, | |||
foreground: colors.black, | |||
backgroundHover: colors.gray8, |
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 trust this was intentional / needed.
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.
Discussed in Flow here: https://www.flowdock.com/app/logos/styled-ui/threads/2G-oohRCEJEeskb1UYx7h5GXr7Z
@RobertBolender, my current project is blocked on this component so I'm hoping to get it shipped here soon. Do you have bandwidth to review today? |
React.isValidElement(child) && child.type.isFocusableChild | ||
? React.cloneElement(child, { | ||
ref: registerItem(index), | ||
keyboardHovered: focusedItemIndex === index, |
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.
(non-blocking) "keyboardHovered" strikes me as strange, is this different from "focused"?
Mouse cursors can hover, keyboards cannot.
return ref => { | ||
let newList = [...itemList.current]; | ||
if (itemList.current.length < index) { | ||
newList = newList.slice(0, index); |
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 not understanding the intent of this conditional statement.
Array.slice already handles the case where the "end" parameter is greater than the length of the array:
If end is greater than the length of the sequence, slice extracts through to the end of the sequence (arr.length).
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.
Yep, and that is what it is being used for. I was just trying to avoid some unnecessary work of slicing and extending the array.
onFocusAway={onCloseMenu} | ||
placement="bottom-start" | ||
hideArrow | ||
width={width || Styled.defaultMenuWidth} |
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.
If this defaultMenuWidth
const is only used here and not in styled.jsx
, how would you feel about just hard-coding it here?
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 usually prefer avoiding magic numbers and mixing css and js so I tried to kill two birds with one stone with keeping the styling constants in a separate file.
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 still find it strange for a const that is only used in one location to be defined in a separate location, but I'll leave it as a non-blocking objection.
const childIndex = childrenList.findIndex(child => child.type?.childConfigComponent === name); | ||
return childIndex !== -1 | ||
? [childrenList[childIndex], childrenList.filter((_, index) => index !== childIndex)] | ||
: [null, children]; |
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.
If I'm reading this correctly, the return value of this getConfigChild
function is an array with two elements:
- Either a single config component, if it exists, or else null
- An array of all the children components that are not the config component.
Is that accurate? Would you consider adding a comment to that effect?
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 left a few non-blocking comments, but otherwise looks good to me 👍
No description provided.