Skip to content
Merged
10 changes: 7 additions & 3 deletions packages/@react-spectrum/list/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,18 @@
background-color: var(--spectrum-table-row-background-color-selected-key-focus);
}

/* Box shadow for left, right, and bottom border for selected rows. */
/* Negative block start causes borders to actually be shared between items. Only works if we allow item overflow to be visible, like card focus rings. */
&:after {
inset-block-start: -1px;
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-prev-selected {
/* First item in the ListView should not have a border that extends outside of itself to the top, it doesn't need to share a border space. */
&.react-spectrum-ListViewItem--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-block-start: 0px;
}
}
}
Expand Down
38 changes: 19 additions & 19 deletions packages/@react-spectrum/list/stories/ListView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,24 @@ storiesOf('ListView', module)
(item) => <Item textValue={item.title}><Image src={item.url} /><Text>{item.title}</Text><Text slot="description">JPG</Text></Item>
}
</ListView>
))
.add('overflowMode="truncate" (default)', () => (
<ListView width="250px" overflowMode="truncate">
<Item textValue="row 1">row 1 with a very very very very very long title</Item>
<Item textValue="row 2">
<Text>Text slot with a really really really long name</Text>
<Text slot="description">Description slot with a really really long name</Text>
</Item>
</ListView>
))
.add('overflowMode="wrap"', () => (
<ListView width="250px" overflowMode="wrap">
<Item textValue="row 1">row 1 with a very very very very very long title</Item>
<Item textValue="row 2">
<Text>Text slot with a really really really long name</Text>
<Text slot="description">Description slot with a really really long name</Text>
</Item>
</ListView>
));

storiesOf('ListView/Drag and Drop', module)
Expand Down Expand Up @@ -383,25 +401,7 @@ storiesOf('ListView/Drag and Drop', module)
<Droppable />
<DragExample listViewProps={{selectionStyle: 'highlight', onAction: action('onAction')}} dragHookOptions={{onDragStart: action('dragStart'), onDragEnd: action('dragEnd')}} />
</Flex>
), {description: {data: 'Folders are non-draggable.'}})
.add('overflowMode="truncate" (default)', () => (
<ListView width="250px" overflowMode="truncate">
<Item textValue="row 1">row 1 with a very very very very very long title</Item>
<Item textValue="row 2">
<Text>Text slot with a really really really long name</Text>
<Text slot="description">Description slot with a really really long name</Text>
</Item>
</ListView>
))
.add('overflowMode="wrap"', () => (
<ListView width="250px" overflowMode="wrap">
<Item textValue="row 1">row 1 with a very very very very very long title</Item>
<Item textValue="row 2">
<Text>Text slot with a really really really long name</Text>
<Text slot="description">Description slot with a really really long name</Text>
</Item>
</ListView>
));
), {description: {data: 'Folders are non-draggable.'}});

function Example(props?) {
return (
Expand Down
2 changes: 2 additions & 0 deletions packages/@react-stately/layout/src/ListLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ export class ListLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {

let rect = new Rect(x, y, width - x, rectHeight);
let layoutInfo = new LayoutInfo(node.type, node.key, rect);
// allow overflow so the focus ring/selection ring can extend outside to overlap with the adjacent items borders
layoutInfo.allowOverflow = true;
layoutInfo.estimatedSize = isEstimated;
return {
layoutInfo
Expand Down