Skip to content

[popups] Refine OpenChangeReason #1782

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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

atomiks
Copy link
Contributor

@atomiks atomiks commented Apr 25, 2025

Closes #1773

  • click -> trigger-press
  • hover -> trigger-hover
  • focus -> trigger-focus

Not final reasons:

// Preview Card
OpenChangeReason

// Tooltip
OpenChangeReason | 'disabled'

// Popover
// Dialog
// Alert Dialog
OpenChangeReason | 'close-press'

// Select
OpenChangeReason | 'window-resize' | 'item-press' | 'cancel-open';

// Menu
OpenChangeReason | 'item-press' | 'cancel-open';
  • close-press occurs when clicking the the Close button part
  • item-press occurs when clicking Menu.Item or Select.Item
  • cancel-open occurs when they mouseup after mousedown outside of the menu or select

"type": "((open: boolean, event: Event | undefined, reason: OpenChangeReason | undefined) => void)",
"type": "((open: boolean, event: Event | undefined, reason: {} | undefined) => void)",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaldudak the API extractor can't handle StringUnion | 'extra-string'?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there was a bug in how nested unions were handled. Could you update the extractor to https://pkg.pr.new/michaldudak/react-api-extractor@a21d7b8 and see if it helps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works 👍

Copy link

netlify bot commented Apr 25, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 52cf9d5
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/68214652255e0900086a39b5
😎 Deploy Preview https://deploy-preview-1782--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@atomiks atomiks force-pushed the refine-openchangereason branch from 444f0f4 to 7bacf23 Compare April 25, 2025 10:37
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Apr 30, 2025
@atomiks atomiks force-pushed the refine-openchangereason branch from fd746da to cbd2316 Compare April 30, 2025 06:42
@atomiks atomiks marked this pull request as ready for review April 30, 2025 06:46
@atomiks atomiks requested a review from colmtuite as a code owner April 30, 2025 06:46
@mui mui deleted a comment from sonarqubecloud bot May 6, 2025
@@ -248,7 +250,7 @@ export namespace useDialogRoot {
onOpenChange?: (
open: boolean,
event: Event | undefined,
reason: OpenChangeReason | undefined,
reason: DialogOpenChangeReason | undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the publicly exported type here (AlertDialog.Root.OpenChangeReason). If DialogOpenChangeReason is used, devs won't know where to import it from.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose type only imports don't lead to circular dependency issues?

Copy link
Contributor Author

@atomiks atomiks May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generator can't handle the public type of Select.Root.OpenChangeReason. To be fair, the Actions type is also not clear where it exists from at the moment, so I could just do OpenChangeReason, and maybe the generator (or some manual code) can automatically prepend the component name + Root. Would be useful to still have overrides in this case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once I update the API extractor to handle types in namespaces, we shouldn't need to use @type annotations manually. Still, an ability to override could be useful sometimes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem like they're still needed here

Copy link

pkg-pr-new bot commented May 7, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@base-ui-components/react@1782

commit: 52cf9d5

@atomiks atomiks force-pushed the refine-openchangereason branch from 20140fe to 40cd658 Compare May 7, 2025 13:30
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 8, 2025
Signed-off-by: atomiks <cc.glows@gmail.com>
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 12, 2025
@atomiks atomiks force-pushed the refine-openchangereason branch from 042d905 to 52cf9d5 Compare May 12, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refine OpenChangeReason values
2 participants