Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions packages/@react-aria/tooltip/src/useTooltipTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTrig
let {
isDisabled,
trigger,
closeOnPress = true
shouldCloseOnPress = true
} = props;

let tooltipId = useId();
Expand Down Expand Up @@ -103,8 +103,8 @@ export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTrig
};

let onPressStart = () => {
// if closeOnPress is false, we should not close the tooltip
if (!closeOnPress) {
// if shouldCloseOnPress is false, we should not close the tooltip
if (!shouldCloseOnPress) {
return;
}
// no matter how the trigger is pressed, we should close the tooltip
Expand Down
6 changes: 3 additions & 3 deletions packages/@react-spectrum/tooltip/src/TooltipTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {useTooltipTriggerState} from '@react-stately/tooltip';

const DEFAULT_OFFSET = -1; // Offset needed to reach 4px/5px (med/large) distance between tooltip and trigger button
const DEFAULT_CROSS_OFFSET = 0;
const DEFAULT_CLOSE_ON_PRESS = true; // Whether the tooltip should close when the trigger is pressed
const DEFAULT_SHOULD_CLOSE_ON_PRESS = true; // Whether the tooltip should close when the trigger is pressed

function TooltipTrigger(props: SpectrumTooltipTriggerProps) {
let {
Expand All @@ -31,7 +31,7 @@ function TooltipTrigger(props: SpectrumTooltipTriggerProps) {
isDisabled,
offset = DEFAULT_OFFSET,
trigger: triggerAction,
closeOnPress = DEFAULT_CLOSE_ON_PRESS
shouldCloseOnPress = DEFAULT_SHOULD_CLOSE_ON_PRESS
} = props;

let [trigger, tooltip] = React.Children.toArray(children) as [ReactElement, ReactElement];
Expand All @@ -43,7 +43,7 @@ function TooltipTrigger(props: SpectrumTooltipTriggerProps) {
let {triggerProps, tooltipProps} = useTooltipTrigger({
isDisabled,
trigger: triggerAction,
closeOnPress
shouldCloseOnPress
}, state, tooltipTriggerRef);

let [borderRadius, setBorderRadius] = useState(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const argTypes = {
children: {
control: {disable: true}
},
closeOnPress: {
shouldCloseOnPress: {
control: 'boolean'
}
};
Expand Down Expand Up @@ -117,7 +117,7 @@ export default {
<Tooltip>Change Name</Tooltip>
],
onOpenChange: action('openChange'),
closeOnPress: true
shouldCloseOnPress: true
},
argTypes: argTypes
} as Meta<typeof TooltipTrigger>;
Expand Down
8 changes: 4 additions & 4 deletions packages/@react-spectrum/tooltip/test/TooltipTrigger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@ describe('TooltipTrigger', function () {
expect(queryByRole('tooltip')).toBeNull();
});

it('does not close if the trigger is clicked when closeOnPress is false', async () => {
it('does not close if the trigger is clicked when shouldCloseOnPress is false', async () => {
let {getByRole, getByLabelText} = render(
<Provider theme={theme}>
<TooltipTrigger onOpenChange={onOpenChange} delay={0} closeOnPress={false}>
<TooltipTrigger onOpenChange={onOpenChange} delay={0} shouldCloseOnPress={false}>
<ActionButton aria-label="trigger" />
<Tooltip>Helpful information.</Tooltip>
</TooltipTrigger>
Expand All @@ -351,10 +351,10 @@ describe('TooltipTrigger', function () {
expect(tooltip).toBeVisible();
});

it('does not close if the trigger is clicked with the keyboard when closeOnPress is false', async () => {
it('does not close if the trigger is clicked with the keyboard when shouldCloseOnPress is false', async () => {
let {getByRole, getByLabelText} = render(
<Provider theme={theme}>
<TooltipTrigger onOpenChange={onOpenChange} delay={0} closeOnPress={false}>
<TooltipTrigger onOpenChange={onOpenChange} delay={0} shouldCloseOnPress={false}>
<ActionButton aria-label="trigger" />
<Tooltip>Helpful information.</Tooltip>
</TooltipTrigger>
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-types/tooltip/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface TooltipTriggerProps extends OverlayTriggerProps {
* Whether the tooltip should close when the trigger is pressed.
* @default true
*/
closeOnPress?: boolean
shouldCloseOnPress?: boolean
}

export interface SpectrumTooltipTriggerProps extends Omit<TooltipTriggerProps, 'closeDelay'>, PositionProps {
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/s2-docs/pages/s2/Tooltip.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const description = 'Displays a description of an element on hover or foc

<PageDescription>{docs.exports.Tooltip.description}</PageDescription>

```tsx render docs={docs.exports.TooltipTrigger} links={docs.links} props={['placement', 'crossOffset', 'shouldFlip']} type="s2"
```tsx render docs={docs.exports.TooltipTrigger} links={docs.links} props={['placement', 'crossOffset', 'shouldFlip', 'shouldCloseOnPress']} type="s2"
"use client";
import {Tooltip, TooltipTrigger, ActionButton} from '@react-spectrum/s2';
import Edit from '@react-spectrum/s2/icons/Edit';
Expand Down