Skip to content

Conversation

@quisido
Copy link
Contributor

@quisido quisido commented Jan 9, 2026

Sorry for these little pings.

This is the same issue as #9453 but for OverlayTriggerState.

This example fails ESLint which expects the methods close, open, etc. to be bound to the state object.

const { close } = useOverlayTriggerState(); // ❌
<DismissButton onDismiss={close} />
image

even:

<DismissButton onDismiss={overlayTriggerState.close} /> // ❌
image

@devongovett
Copy link
Member

state methods are not intended to be unbound, so the error is correct. It should be:

<DismissButton onDismiss={() => state.close()} />

@quisido
Copy link
Contributor Author

quisido commented Jan 9, 2026

state methods are not intended to be unbound, so the error is correct. It should be:

<DismissButton onDismiss={() => state.close()} />

This differs from the React Aria documentation:

<DismissButton onDismiss={state.close} />

I can see from the implementation that they are unbound, and can confirm at runtime that they are unbound. The unbound example in the documentation works as expected.

@snowystinger
Copy link
Member

This differs from the React Aria documentation:

<DismissButton onDismiss={state.close} />

I can see from the implementation that they are unbound, and can confirm at runtime that they are unbound. The unbound example in the documentation works as expected.

We should fix our docs then, this way it isn't breaking should we ever use it in a bound way in the future

@quisido
Copy link
Contributor Author

quisido commented Jan 9, 2026

For my own conceptualization while working with this library, what's the philosophy behind Filters being unbound but States being bound? Is it that other component states are bound but OverlayTriggerState just coincidentally isn't?

@snowystinger
Copy link
Member

useFilter is stateless, and I don't think it'll ever have state

useOverlayTriggerState has state, and may, like some of our other state hooks, need bound references. It's just coincidence that, right now, it doesn't have any.

I think a general rule of thumb is, if it's in aria you can destructure it and if it's in stately, you shouldn't.

There may be exceptions to that distinction, it's not something we've been very strict about.

@devongovett feel free to correct me

@quisido quisido closed this Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants