Skip to content

Commit 68004a1

Browse files
ktaborsyihuiliaoreidbarber
authored
RAC Tooltip: add support of prop shouldFlip (#6147)
Co-authored-by: Yihui Liao <44729383+yihuiliao@users.noreply.github.com> Co-authored-by: Reid Barber <reid@reidbarber.com>
1 parent 884a766 commit 68004a1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/react-aria-components/src/Tooltip.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ function TooltipInner(props: TooltipProps & {isExiting: boolean, tooltipRef: Ref
137137
crossOffset: props.crossOffset,
138138
isOpen: state.isOpen,
139139
arrowSize: arrowWidth,
140-
arrowBoundaryOffset: props.arrowBoundaryOffset
140+
arrowBoundaryOffset: props.arrowBoundaryOffset,
141+
shouldFlip: props.shouldFlip
141142
});
142143

143144
let isEntering = useEnterAnimation(props.tooltipRef, !!placement) || props.isEntering || false;

packages/react-aria-components/stories/Tooltip.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const TooltipArrowBoundaryOffsetExample = {
115115
<Button style={{width: 200, height: 100}}>Top left</Button>
116116
<Tooltip
117117
placement="top left"
118+
shouldFlip={false}
118119
offset={7}
119120
arrowBoundaryOffset={topLeft}
120121
style={{
@@ -138,6 +139,7 @@ export const TooltipArrowBoundaryOffsetExample = {
138139
<Button style={{width: 200, height: 100}}>Top right</Button>
139140
<Tooltip
140141
placement="top right"
142+
shouldFlip={false}
141143
offset={7}
142144
arrowBoundaryOffset={topRight}
143145
style={{
@@ -163,6 +165,7 @@ export const TooltipArrowBoundaryOffsetExample = {
163165
<Button style={{width: 200, height: 100}}>Left top</Button>
164166
<Tooltip
165167
placement="left top"
168+
shouldFlip={false}
166169
offset={7}
167170
arrowBoundaryOffset={leftTop}
168171
style={{
@@ -186,6 +189,7 @@ export const TooltipArrowBoundaryOffsetExample = {
186189
<Button style={{width: 200, height: 100}}>Left bottom</Button>
187190
<Tooltip
188191
placement="left bottom"
192+
shouldFlip={false}
189193
offset={7}
190194
arrowBoundaryOffset={leftBotton}
191195
style={{
@@ -211,6 +215,7 @@ export const TooltipArrowBoundaryOffsetExample = {
211215
<Button style={{width: 200, height: 100}}>Right top</Button>
212216
<Tooltip
213217
placement="right top"
218+
shouldFlip={false}
214219
offset={7}
215220
arrowBoundaryOffset={rightTop}
216221
style={{
@@ -234,6 +239,7 @@ export const TooltipArrowBoundaryOffsetExample = {
234239
<Button style={{width: 200, height: 100}}>Right bottom</Button>
235240
<Tooltip
236241
placement="right bottom"
242+
shouldFlip={false}
237243
offset={7}
238244
arrowBoundaryOffset={rightBottom}
239245
style={{
@@ -259,6 +265,7 @@ export const TooltipArrowBoundaryOffsetExample = {
259265
<Button style={{width: 200, height: 100}}>Bottom left</Button>
260266
<Tooltip
261267
placement="bottom left"
268+
shouldFlip={false}
262269
offset={7}
263270
arrowBoundaryOffset={bottomLeft}
264271
style={{
@@ -282,6 +289,7 @@ export const TooltipArrowBoundaryOffsetExample = {
282289
<Button style={{width: 200, height: 100}}>Bottom right</Button>
283290
<Tooltip
284291
placement="bottom right"
292+
shouldFlip={false}
285293
offset={7}
286294
arrowBoundaryOffset={bottomRight}
287295
style={{

0 commit comments

Comments
 (0)