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

Dropdown v6 Update #379

Merged
merged 18 commits into from
Nov 5, 2020
Merged

Conversation

korbinancell
Copy link
Contributor

No description provided.

@korbinancell korbinancell changed the title Split button Dropdown v6 Update Nov 3, 2020
@rmjohnson
Copy link
Contributor

My non-designer eyes can't tell for certain but it looks like the arrow isn't vertically aligned (feels a little closer to the top than the bottom).
image

@@ -0,0 +1,132 @@
- [✔] Styled Systems support
- [✔] WAI-ARIA compliant
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

@@ -3,7 +3,7 @@ import { resetStyles } from '../utils';
import { Box } from '../Box';

export const CheckboxDiv = styled(Box)`
position: absolute;
position: ${({ position }) => position || 'absolute'};
Copy link
Contributor

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}
Copy link
Contributor

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'),
Copy link
Contributor

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) {
Copy link
Contributor

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,
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rmjohnson
Copy link
Contributor

@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,
Copy link
Contributor

@RobertBolender RobertBolender Nov 4, 2020

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);
Copy link
Contributor

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).

Copy link
Contributor Author

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}
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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];
Copy link
Contributor

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:

  1. Either a single config component, if it exists, or else null
  2. 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?

Copy link
Contributor

@RobertBolender RobertBolender left a 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 👍

@korbinancell korbinancell merged commit 1168be9 into Faithlife:master Nov 5, 2020
@RobertBolender RobertBolender mentioned this pull request Dec 22, 2020
40 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants