Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
1d49a64
making quiet listviews not have rounded corners and borders between rows
LFDanLu Feb 2, 2022
4420acc
matching active/hover state for ListView selected row with TableView
LFDanLu Feb 2, 2022
8fdfef9
adding user-select: none to listview
LFDanLu Feb 2, 2022
72b674b
adding left border and background opacity to listview focused row
LFDanLu Feb 3, 2022
7ee30d1
updating tableview highlight selction selected row left and right bor…
LFDanLu Feb 3, 2022
4512b88
fixing top/bottom border for first and last row in highlight table
LFDanLu Feb 3, 2022
cf41f67
moving left indicator to a :before of the ListView row div
LFDanLu Feb 3, 2022
9a2d3f7
fixing lint
LFDanLu Feb 3, 2022
d172d78
removing extraneous border
LFDanLu Feb 4, 2022
06f93e6
hiding bottom border of last row to avoid overlap with container border
LFDanLu Feb 7, 2022
2011fae
making the focus ring indicator sticky for TableView and ListView
LFDanLu Feb 10, 2022
1767089
removing extraneous focus ring indicator
LFDanLu Feb 10, 2022
5c6ea85
fixing borders to remove wiggles
LFDanLu Feb 14, 2022
24af3c6
fix lint
LFDanLu Feb 14, 2022
d5e4a94
Merge branch 'main' into issue_2611
LFDanLu Feb 14, 2022
9b63316
Merge branch 'main' of github.com:adobe/react-spectrum into issue_2611
LFDanLu Feb 15, 2022
eebb2b5
adding pointer-events none to :after box shadow
LFDanLu Feb 15, 2022
2aab429
addressing review comments
LFDanLu Feb 15, 2022
70a4fc7
Merge branch 'main' into issue_2611
LFDanLu Feb 25, 2022
c0725e8
Merge branch 'main' into issue_2611
LFDanLu Feb 28, 2022
cc7a836
Merge branch 'main' of github.com:adobe/react-spectrum into issue_2611
LFDanLu Feb 28, 2022
a344906
fix firefox and safari table checkbox positioning when row focus is v…
LFDanLu Mar 1, 2022
ac3c4cb
replacing border-top for table highlight selection first row with box…
LFDanLu Mar 1, 2022
db50827
removing extra space
LFDanLu Mar 1, 2022
cfdc2d4
Merge branch 'main' into issue_2611
LFDanLu Mar 1, 2022
594013a
Merge branch 'main' into issue_2611
LFDanLu Mar 7, 2022
eb50f41
Merge branch 'main' into issue_2611
LFDanLu Mar 10, 2022
e42de7b
making last row only have rounded corners if we are not loading more …
LFDanLu Mar 10, 2022
4bebdf2
fix sticky focus ring rtl
LFDanLu Mar 11, 2022
4252b28
removing transition from listview to match tableview
LFDanLu Mar 11, 2022
509e005
adding blue outline for selected tableview row and replacing bottom b…
LFDanLu Mar 12, 2022
fc1b79c
simplifying the box-shadow tableview css
LFDanLu Mar 12, 2022
3e914dc
update listview css to use box shadows instead of border
LFDanLu Mar 12, 2022
e73c49d
fixing vertical padding and horizontal padding for dnd
LFDanLu Mar 12, 2022
83505c1
fixing z-index for left focus indicator
LFDanLu Mar 14, 2022
5fba763
making tableview follow the same .5px box shadow like listview
LFDanLu Mar 14, 2022
d684ffc
Merge branch 'main' into issue_2611
LFDanLu Mar 15, 2022
112276b
fixing listview first and last row styles
LFDanLu Mar 15, 2022
6901cf7
Revert "making tableview follow the same .5px box shadow like listview"
LFDanLu Mar 15, 2022
0c72b90
removing todo comment
LFDanLu Mar 15, 2022
1773747
Merge branch 'main' of github.com:adobe/react-spectrum into issue_2611
LFDanLu Mar 23, 2022
3144468
applying tableview style updates to deprecated tableview too
LFDanLu Apr 1, 2022
2eaa09c
Merge branch 'main' into issue_2611
LFDanLu Apr 1, 2022
079512a
Merge branch 'main' into issue_2611
LFDanLu Apr 4, 2022
d2940ec
Merge branch 'main' into issue_2611
LFDanLu Apr 6, 2022
ee97f27
Merge branch 'main' into issue_2611
LFDanLu Apr 7, 2022
6999781
making rounded corners only happen if table/list content is greater o…
LFDanLu Apr 8, 2022
b776da4
fixing border radius for first/last row TableView
LFDanLu Apr 8, 2022
5ed63b5
going back to -1px bottom border strategy instead of .5px for ListView
LFDanLu Apr 8, 2022
276c282
removing lastRow bottom border for listview if content is equal or gr…
LFDanLu Apr 8, 2022
718ba65
Merge branch 'main' into issue_2611
LFDanLu Apr 13, 2022
458ecf6
Merge branch 'main' of github.com:adobe/react-spectrum into issue_2611
LFDanLu Apr 18, 2022
2c0e8b1
removing contain: paint since overflow styles should handle that for us
LFDanLu Apr 18, 2022
11770b6
Merge branch 'main' into issue_2611
LFDanLu Apr 23, 2022
f9c6081
Merge branch 'main' into issue_2611
dannify Apr 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions packages/@adobe/spectrum-css-temp/components/table/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ governing permissions and limitations under the License.
--spectrum-table-cell-compact-padding-y: var(--spectrum-global-dimension-size-75);
--spectrum-table-cell-regular-padding-y: var(--spectrum-global-dimension-size-125);
--spectrum-table-cell-spacious-padding-y: var(--spectrum-global-dimension-size-175);
--spectrum-table-row-border-radius: calc(var(--spectrum-table-border-radius) - 1px);
--spectrum-table-row-sticky-focus-indicator-width: 3px;
}

.spectrum-Table {
Expand Down Expand Up @@ -104,7 +106,7 @@ svg.spectrum-Table-sortedIcon {
block-size: 100%;
cursor: col-resize;
user-select: none;

&::after {
content: "";
position: absolute;
Expand All @@ -114,7 +116,7 @@ svg.spectrum-Table-sortedIcon {
block-size: 100%;
background-color: var(--spectrum-table-divider-border-color);
}

&:active,
&:focus {
&::after {
Expand Down Expand Up @@ -291,16 +293,22 @@ svg.spectrum-Table-sortedIcon {
outline: 0;
}

/* The focus ring must be on top of the first cell, so needs to be absolutely positioned. */
/* The focus ring should be sticky so it is visible at all horizontal scroll positions. */
&:focus-ring {
&:before {
display: inline-block;
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: var(--spectrum-selectlist-border-size-key-focus);
z-index: 3;
position: sticky;
inset-inline-start: 0;
height: 100%;
width: var(--spectrum-table-row-sticky-focus-indicator-width);
z-index: 4;
margin-inline-end: calc(var(--spectrum-table-row-sticky-focus-indicator-width) * -1);
}

.spectrum-Table-cellWrapper:first-of-type {
display: inline-block;
vertical-align: top;
}
}

Expand All @@ -309,6 +317,28 @@ svg.spectrum-Table-sortedIcon {
}
}

.spectrum-Table:not(.spectrum-Table--loadingMore):not(.spectrum-Table--quiet) {
.spectrum-Table-row {
&.spectrum-Table-row--lastRow.spectrum-Table-row--isFlushBottom.is-selected {
&:after {
border-end-start-radius: var(--spectrum-table-row-border-radius);
border-end-end-radius: var(--spectrum-table-row-border-radius);
}
}
}
}

.spectrum-Table:not(.spectrum-Table--quiet) {
.spectrum-Table-row {
&.spectrum-Table-row--firstRow.is-selected {
&:after {
border-start-start-radius: var(--spectrum-table-row-border-radius);
border-start-end-radius: var(--spectrum-table-row-border-radius);
}
}
}
}

/* the CSS logical properties postcss plugin doesn't seem to work with :focus-ring. */
[dir="rtl"] .spectrum-Table-row:focus-ring:before {
right: 0;
Expand Down
43 changes: 40 additions & 3 deletions packages/@adobe/spectrum-css-temp/components/table/skin.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ tbody.spectrum-Table-body {
}

.spectrum-Table-row {
border-bottom: 1px solid var(--spectrum-table-cell-border-color);
box-sizing: border-box;

.spectrum-Table-cellWrapper {
Expand Down Expand Up @@ -149,6 +148,32 @@ tbody.spectrum-Table-body {
background-color: var(--spectrum-table-row-background-color-down);
}

/* Alternative to border on rows. Using box shadow since they don't take room unlike border which would cause wiggles
* in the hightlight case and displace the sticky indicator. Also allows for a nicer bottom curved border to match the container,
* the bottom border curved corners were cut off when using borders.
*/

/* Box shadow for bottom border for non-selected rows that aren't immediatly above a selected row. */
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately cannot omit the bottom border of the last row like we do in ListView due to how the row vs cell is structured (aka row is 1px larger than the cell, controlled by layout, cell is responsible for filling in the background color, cell focus ring cut off if we reduce the row height, etc). Can be investigated further as follow up

&:after {
box-shadow: inset 0 -1px 0 0 var(--spectrum-table-cell-border-color);
content: '';
display: block;
position: absolute;
inset-inline-start: 0;
inset-inline-end: 0;
inset-block-end: 0;
inset-block-start: 0;
z-index: 3;
pointer-events: none;
}

/* Box shadow for bottom border for non-selected row that is immediatly above a selected row. */
&.is-next-selected {
&:after {
box-shadow: inset 0 -1px 0 0 var(--spectrum-global-color-blue-500);
}
}

&.is-selected {
.spectrum-Table-cell {
background-color: var(--spectrum-table-row-background-color-selected);
Expand All @@ -163,10 +188,22 @@ tbody.spectrum-Table-body {
&.is-focused .spectrum-Table-cell {
background-color: var(--spectrum-table-row-background-color-selected-key-focus);
}

/* Box shadow for bottom, left, and right border for selected rows. */
&:after {
box-shadow: inset 1px 0 0 0 var(--spectrum-global-color-blue-500), inset -1px 0 0 0 var(--spectrum-global-color-blue-500), inset 0 -1px 0 0 var(--spectrum-global-color-blue-500);
}
}

&.spectrum-Table-row--highlightSelection {
border-bottom-color: var(--spectrum-global-color-blue-500);
/* Box shadow for bottom, left, right, and top border for first row when selected. When the row isn't selected, it doesn't need
* a top border.
*/
&.spectrum-Table-row--firstRow {
&.is-selected {
&:after {
box-shadow: inset 1px 0 0 0 var(--spectrum-global-color-blue-500), inset -1px 0 0 0 var(--spectrum-global-color-blue-500), inset 0 1px 0 0 var(--spectrum-global-color-blue-500), inset 0 -1px 0 0 var(--spectrum-global-color-blue-500);
}
}
}

&.is-drop-target {
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-aria/virtualizer/src/VirtualizerItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent
opacity: layoutInfo.opacity,
zIndex: layoutInfo.zIndex,
transform: layoutInfo.transform,
contain: layoutInfo.allowOverflow ? 'size layout style' : 'size layout style paint'
contain: 'size layout style'
Copy link
Member Author

Choose a reason for hiding this comment

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

fixes issue with sticky checkboxes and focus indicator not sticking properly in Safari 15.4. Don't think we need paint since we have overflow handling that for us in the VirtualizerItem style. Lemme know if you think we should keep it as is, the Safari 15.4 bug is fixed and may be coming out soonish, but I feel like the above change is still more "correct"

};

cache.set(layoutInfo, style);
Expand Down
16 changes: 9 additions & 7 deletions packages/@react-spectrum/list/src/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ import React, {ReactElement, useContext, useMemo, useRef} from 'react';
import {useCollator, useLocale, useMessageFormatter} from '@react-aria/i18n';
import {Virtualizer} from '@react-aria/virtualizer';

interface ListViewContextValue {
state: GridState<object, GridCollection<any>>,
keyboardDelegate: GridKeyboardDelegate<unknown, GridCollection<any>>,
interface ListViewContextValue<T> {
state: GridState<T, GridCollection<any>>,
keyboardDelegate: GridKeyboardDelegate<T, GridCollection<any>>,
dragState: DraggableCollectionState,
onAction:(key: string) => void,
isListDraggable: boolean
isListDraggable: boolean,
layout: ListLayout<T>
}

export const ListViewContext = React.createContext<ListViewContextValue>(null);
export const ListViewContext = React.createContext<ListViewContextValue<unknown>>(null);

const ROW_HEIGHTS = {
compact: {
Expand Down Expand Up @@ -237,7 +238,7 @@ function ListView<T extends object>(props: ListViewProps<T>, ref: DOMRef<HTMLDiv
}

return (
<ListViewContext.Provider value={{state, keyboardDelegate, dragState, onAction, isListDraggable}}>
<ListViewContext.Provider value={{state, keyboardDelegate, dragState, onAction, isListDraggable, layout}}>
<Virtualizer
{...gridProps}
{...styleProps}
Expand All @@ -254,7 +255,8 @@ function ListView<T extends object>(props: ListViewProps<T>, ref: DOMRef<HTMLDiv
'react-spectrum-ListView--emphasized',
{
'react-spectrum-ListView--quiet': isQuiet,
'react-spectrum-ListView--draggable': isListDraggable
'react-spectrum-ListView--draggable': isListDraggable,
'react-spectrum-ListView--loadingMore': loadingState === 'loadingMore'
},
styleProps.className
)
Expand Down
31 changes: 28 additions & 3 deletions packages/@react-spectrum/list/src/ListViewItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export function ListViewItem(props) {
dragHooks
} = props;
let cellNode = [...item.childNodes][0];
let {state, dragState, onAction, isListDraggable} = useContext(ListViewContext);
let {state, dragState, onAction, isListDraggable, layout} = useContext(ListViewContext);

let {direction} = useLocale();
let rowRef = useRef<HTMLDivElement>();
let cellRef = useRef<HTMLDivElement>();
Expand Down Expand Up @@ -97,9 +98,30 @@ export function ListViewItem(props) {
let isSelected = state.selectionManager.isSelected(item.key);
let showDragHandle = isDraggable && isFocusVisibleWithin;
let {visuallyHiddenProps} = useVisuallyHidden();
let isFirstRow = item.prevKey == null;
Copy link
Member

Choose a reason for hiding this comment

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

I thought ListView did items not rows?

Copy link
Member Author

Choose a reason for hiding this comment

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

it uses Item but still follows the grid row/cell pattern. The above change was made just for code consistency/clarity

let isLastRow = item.nextKey == null;
// Figure out if the ListView content is equal or greater in height to the container. If so, we'll need to round the bottom
// border corners of the last row when selected and we can get rid of the bottom border if it isn't selected to avoid border overlap
// with bottom border
let isFlushWithContainerBottom = false;
if (isLastRow) {
if (layout.getContentSize()?.height >= layout.virtualizer?.getVisibleRect().height) {
isFlushWithContainerBottom = true;
}
}

return (
<div
{...mergeProps(rowProps, pressProps, isDraggable && draggableItem?.dragProps)}
className={
classNames(
listStyles,
'react-spectrum-ListView-row',
{
'focus-ring': isFocusVisible
}
)
}
ref={rowRef}>
<div
className={
Expand All @@ -112,9 +134,12 @@ export function ListViewItem(props) {
'focus-ring': isFocusVisible,
'is-hovered': isHovered,
'is-selected': isSelected,
'is-previous-selected': state.selectionManager.isSelected(item.prevKey),
'is-next-selected': state.selectionManager.isSelected(item.nextKey),
'react-spectrum-ListViewItem--highlightSelection': state.selectionManager.selectionBehavior === 'replace' && (isSelected || state.selectionManager.isSelected(item.nextKey)),
'react-spectrum-ListViewItem--draggable': isDraggable
'react-spectrum-ListViewItem--draggable': isDraggable,
'react-spectrum-ListViewItem--firstRow': isFirstRow,
'react-spectrum-ListViewItem--lastRow': isLastRow,
'react-spectrum-ListViewItem--isFlushBottom': isFlushWithContainerBottom
}
)
}
Expand Down
Loading