Skip to content

Conversation

@jandrade
Copy link
Member

Summary:

Next step on the Floating component:

  • Adds portal prop and copies maybeGetPortalMountedModalHostElement from WB
    Modal.

Implementation plan:

  1. [WB-2111.1] Create wonder-blocks-floating package #2835
  2. [WB-2111.2] Add Floating component (base props + middlewares) #2842
  3. Add portal prop to Floating component (this PR)
  4. Add focus management
  5. Add style prop and RTL support

Issue: https://khanacademy.atlassian.net/browse/WB-2111

Test plan:

Navigate to the Floating component stories and verify that the portal example
works as expected. This means that the floating content should be rendered
inside the modal host element.

Also verify that this looks and works good in the Floating Testing Snapshots
story.

…s maybeGetPortalMountedModalHostElement from WB Modal.
@jandrade jandrade self-assigned this Oct 31, 2025
@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2025

🦋 Changeset detected

Latest commit: 938b356

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/wonder-blocks-floating Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2025

Size Change: +229 B (+0.21%)

Total Size: 111 kB

Filename Size Change
packages/wonder-blocks-floating/dist/es/index.js 2.41 kB +229 B (+10.52%) ⚠️
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3 kB
packages/wonder-blocks-announcer/dist/es/index.js 1.74 kB
packages/wonder-blocks-badge/dist/es/index.js 2.02 kB
packages/wonder-blocks-banner/dist/es/index.js 2.01 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.92 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 755 B
packages/wonder-blocks-button/dist/es/index.js 4.25 kB
packages/wonder-blocks-card/dist/es/index.js 1.01 kB
packages/wonder-blocks-cell/dist/es/index.js 2.19 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.66 kB
packages/wonder-blocks-core/dist/es/index.js 2.48 kB
packages/wonder-blocks-data/dist/es/index.js 5.48 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.4 kB
packages/wonder-blocks-form/dist/es/index.js 6.2 kB
packages/wonder-blocks-grid/dist/es/index.js 1.24 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3.16 kB
packages/wonder-blocks-icon/dist/es/index.js 1.91 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 3.48 kB
packages/wonder-blocks-layout/dist/es/index.js 1.63 kB
packages/wonder-blocks-link/dist/es/index.js 1.52 kB
packages/wonder-blocks-modal/dist/es/index.js 6.99 kB
packages/wonder-blocks-pill/dist/es/index.js 1.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.3 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.1 kB
packages/wonder-blocks-styles/dist/es/index.js 464 B
packages/wonder-blocks-switch/dist/es/index.js 1.55 kB
packages/wonder-blocks-tabs/dist/es/index.js 3.71 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.25 kB
packages/wonder-blocks-testing/dist/es/index.js 978 B
packages/wonder-blocks-theming/dist/es/index.js 384 B
packages/wonder-blocks-timing/dist/es/index.js 1.37 kB
packages/wonder-blocks-tokens/dist/es/index.js 5.01 kB
packages/wonder-blocks-toolbar/dist/es/index.js 906 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.4 kB
packages/wonder-blocks-typography/dist/es/index.js 1.57 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2025

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-bhboquneld.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 4
Tests with visual changes 1
Total stories 742
Inherited (not captured) snapshots [TurboSnap] 440
Tests on the build 442

import {Meta} from "@storybook/addon-docs/blocks";

<Meta title="Packages / Floating / Floating / Accessibility" />
<Meta title="Packages / Floating / Accessibility" />
Copy link
Member Author

Choose a reason for hiding this comment

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

note: Moved this one level down to be consistent with the rest of the packages with only one export.

Copy link
Member Author

Choose a reason for hiding this comment

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

note: For some reason, I had this inside the code, so I got rid of it.

hideProp ? hide() : undefined,
],
});
const {elements, refs, floatingStyles, context, middlewareData} =
Copy link
Member Author

Choose a reason for hiding this comment

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

note: The only change here is adding elements so we can pass it to the Portal instance. The rest are formatting changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

note: I copied this from wb-modal and adapted it to work here (changed to WB imports).

Copy link
Member Author

Choose a reason for hiding this comment

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

note: copied this from wb-modal to centralize that logic here. One the migration is done, I'll be removing the wb-modal copy.

@jandrade jandrade marked this pull request as ready for review October 31, 2025 15:36
@khan-actions-bot khan-actions-bot requested a review from a team October 31, 2025 15:36
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to pnpm-lock.yaml, .changeset/young-icons-love.md, __docs__/wonder-blocks-floating/floating-testing-snapshots.stories.tsx, __docs__/wonder-blocks-floating/floating.accessibility.mdx, __docs__/wonder-blocks-floating/floating.stories.tsx, packages/wonder-blocks-floating/package.json, packages/wonder-blocks-floating/tsconfig-build.json, packages/wonder-blocks-floating/src/components/floating-portal.tsx, packages/wonder-blocks-floating/src/components/floating.tsx, packages/wonder-blocks-floating/src/util/constants.ts, packages/wonder-blocks-floating/src/util/maybe-get-portal-mounted-modal-host-element.ts, packages/wonder-blocks-floating/src/components/__tests__/floating-portal.test.tsx, packages/wonder-blocks-floating/src/util/__tests__/maybe-get-portal-mounted-modal-host-element.test.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@github-actions
Copy link
Contributor

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (f2fd3d0) and published all packages with changesets to npm.

You can install the packages in frontend by running:

./dev/tools/deploy_wonder_blocks.js --tag="PR2844"

Packages can also be installed manually by running:

pnpm add @khanacademy/wonder-blocks-<package-name>@PR2844

Copy link
Member

@somewhatabstract somewhatabstract left a comment

Choose a reason for hiding this comment

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

LGTM

Exciting to see this work happening!

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.

4 participants