Skip to content

Conversation

@snowystinger
Copy link
Member

Closes

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@snowystinger
Copy link
Member Author

snowystinger commented May 5, 2022

I've only implemented this for single selection mode so far. It should look like this:
Screen Shot 2022-05-05 at 10 18 00 AM
Screen Shot 2022-05-05 at 10 18 06 AM

Multiple selection mode is a little odd, off the bat it looks like this:
Screen Shot 2022-05-05 at 10 19 09 AM

So the question is, do we want to do square corners for ranges but round the first and last for multiple? like this:
Screen Shot 2022-05-05 at 11 17 21 AM
I've committed this so you can see it live as well

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@snowystinger snowystinger changed the title Round ListView item borders in single selection Round ListView item borders in quiet May 5, 2022
@majornista
Copy link
Collaborator

+1 for rounded corners on first and last of a group of selected items. Looks sophisticated.

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

I definitely like the square corners for quiet + multiple selection when consecutive rows are selected. Should the hover style and keyboard focused but not selected style have rounded corners as well?
Hover style:
image

keyboard focus but not selected:
image

background-color: var(--spectrum-alias-background-color-transparent);
border-width: 0;
border-radius: 0;
&:not(.react-spectrum-ListView--multipleSelection) {
Copy link
Member

Choose a reason for hiding this comment

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

This is... quite the CSS. Not sure I follow completely, but there's no way this can be simplified?

Copy link
Member Author

Choose a reason for hiding this comment

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

I see a place i can simplify a little 👍🏻

@devongovett
Copy link
Member

A weird case
image

# Conflicts:
#	packages/@react-spectrum/list/src/ListView.tsx
#	packages/@react-spectrum/list/src/styles.css
@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉


let hasAnyChildren = useMemo(() => [...collection].some(item => item.hasChildNodes), [collection]);
let [hoveredKey, setHoveredKey] = useState<Key>();
let hoverState = {hoveredKey, setHoveredKey};
Copy link
Member

Choose a reason for hiding this comment

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

lol might be overkill but let's see what people think. IMO it's a little strange that the corners change when hovering over an adjacent item 😂

Copy link
Member Author

Choose a reason for hiding this comment

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

import type {DraggableItemResult} from '@react-aria/dnd';
import {FocusRing, useFocusRing} from '@react-aria/focus';
import {Grid} from '@react-spectrum/layout';
import {isFocusVisible as isFocusVisibleFn, useHover, usePress} from '@react-aria/interactions';
Copy link
Member

Choose a reason for hiding this comment

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

isGlobalFocusVisible?

Copy link
Member Author

Choose a reason for hiding this comment

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

assuming this is just a naming thing, then I've renamed it

'focus-ring': isFocusVisible
'focus-ring': isFocusVisible,
'round-tops': !state.selectionManager.isSelected(item.prevKey) && (state.selectionManager.focusedKey !== item.prevKey || !isFocusVisibleFn()) && hoverState.hoveredKey !== item.prevKey,
'round-bottoms': !state.selectionManager.isSelected(item.nextKey) && (state.selectionManager.focusedKey !== item.nextKey || !isFocusVisibleFn()) && hoverState.hoveredKey !== item.nextKey
Copy link
Member

Choose a reason for hiding this comment

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

I think the focus visible behavior isn't quite right. It shouldn't be if anything on the page has keyboard modality, it should only be if focus is somewhere inside the listview. Right now if you select something and then tab away from the listview the corners aren't rounded anymore.

Copy link
Member Author

@snowystinger snowystinger May 9, 2022

Choose a reason for hiding this comment

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

fixed in 540adf1
good catch

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉


return (
<ListViewContext.Provider value={{state, dragState, isListDraggable, layout}}>
<ListViewContext.Provider value={{state, dragState, isListDraggable, layout, isFocusWithin}}>
Copy link
Member

Choose a reason for hiding this comment

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

I think selectionManager.isFocused should already have this info?

Copy link
Member Author

Choose a reason for hiding this comment

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

odd, i tried that, but i must have had a bad combo with something else, as it appears to be working when i change that to use selectionManager

@adobe-bot
Copy link

Build successful! 🎉

reidbarber
reidbarber previously approved these changes May 10, 2022
Copy link
Member

@reidbarber reidbarber left a comment

Choose a reason for hiding this comment

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

LGTM, new styles render as expected

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

LGTM, I'll approve if you think we can ignore that wiggle :D

Comment on lines -59 to -64
/* Box shadow for bottom border for non-selected rows that is immmediately above a selected row. */
&.is-next-selected {
&:after {
box-shadow: inset 0 -1px 0 0 var(--spectrum-global-color-blue-500);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Minor note, potentially ignorable:
By simplifying this, a wiggle case has returned:

  1. Go to https://reactspectrum.blob.core.windows.net/reactspectrum/59530d349cab3e68b3c57100957b6659c7effe87/storybook/index.html?path=/story/listview--selection-multiple-checkbox and select the second row.
  2. Repeatedly select and deselect the first row. Note that the border between the two rows wiggles

I'm fine with ignoring it in favor of simpler css, I probably overengineered this css to avoid this wiggle in the first place haha

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll have a look at this separately. good find though

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Approving in case you want to look at Daniel's wiggle separately

@snowystinger snowystinger merged commit 01fafa7 into main May 10, 2022
@snowystinger snowystinger deleted the sidenav-styles-for-listview branch May 10, 2022 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants