adobe / adobe/react-spectrum

Add `PressEvents` to `Tab`

Open
#6,810 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### Provide a general summary of the feature here

On the tails of https://github.com/adobe/react-spectrum/pull/6742, I'd like to request that `Tab` also receive `PressEvents`, just like how a `Button` / `LinkButton` support basically all the same props.

I currently have a need to have a `Tab` to have a secondary action on press, whether it's already active or not. Which means that I can't listen to `onSelectionChange` on `Tabs` since that only fires if the state changes.

My interim solution has been to implement a `div` inside of the `Tab` that utilizes `usePress`, though it then also has to make sure to call `(event) => event.continuePropagation()` on all press events so as to not break the `Tab` behavior

If the `Tab` implemented `PressEvents` then I'd be able to skip this complication and bind directly to the `Tab`

### 🤔 Expected Behavior?

`Tab` supports `PressEvents`

### 😯 Current Behavior

`Tab` doesn't support `PressEvents`

### 💁 Possible Solution

Add `usePress` to `Tab` and `mergeProps` with existing event handlers

### 🔦 Context

I have a set of tabs that are attached to a drawer. The drawer has to open or close if one of the tabs is clicked

### 💻 Examples

_No response_

### 🧢 Your Company/Team

_No response_

### 🕷 Tracking Issue

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.