Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useButton and all react-aria button instances should be able to disable preventDefault. #7968

Open
JuozasIzi1 opened this issue Mar 20, 2025 · 1 comment

Comments

@JuozasIzi1
Copy link

Provide a general summary of the feature here

useButton and all react-aria button instances should be able to disable preventDefault.:

  • Other libraries ( floating ui popover for example) can't see outside click if pressed button like react aria component
    Now i need to hack like this:
 const ref = useRef<HTMLButtonElement | null>(null);
 const { buttonProps } = useButton(props, ref);
 const { children } = props;

  const onPointerDown = (e: any) => {
    buttonProps.onPointerDown?.({
      ...e,
      preventDefault: () => {},
      stopPropagation: () => {},
    });
  };

  return (
    <button {...buttonProps} onPointerDown={onPointerDown} ref={ref}>
      {children}
    </butt

🤔 Expected Behavior?

  • Expected to be able trasnmit all data of press.

😯 Current Behavior

Currently librabries can't detect outside click if react-aria button clicked

💁 Possible Solution

provide props to prevent this behaviour

🔦 Context

Floating ui doesn't get outside click and doesn't close popover. (And i would not want to use overlay, because i need scroll events also)

💻 Examples

No response

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@devongovett
Copy link
Member

As of the latest release, usePress no longer calls preventDefault. See https://react-spectrum.adobe.com/releases/2025-03-05.html#usepress-update. Are you using the latest version?

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

No branches or pull requests

2 participants