Skip to content

Conversation

@ysds
Copy link
Contributor

@ysds ysds commented Dec 22, 2025

Summary

Deep merge floatingUIOptions to preserve internal settings when custom options are passed.

Rationale

Closes #2308

Changes

  • Use lodash.merge instead of spread operator for deep merging floatingUIOptions in all controller components
  • Add satisfies FloatingUIOptions to the first argument of merge() to maintain type inference for callback parameters (e.g., onOpenChange)
  • Use nested object spreads to deep merge floatingUIOptions in all controller components (no new dependencies required)
  • Fix the type of floatingUIOptions prop in SuggestionMenuController from UseFloatingOptions to FloatingUIOptions

Impact

Users can now pass partial floatingUIOptions without losing the controller's internal default settings.

Testing

Build passes.

Screenshots/Video

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

@vercel
Copy link

vercel bot commented Dec 22, 2025

@ysds is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@nperez0111 nperez0111 left a comment

Choose a reason for hiding this comment

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

Hi @ysds, I appreciate you opening this pull request, but unfortunately we cannot take this as is. We definitely don't want to pull in lodash.merge as a dependency for what could be accomplished with another object spread

@ysds
Copy link
Contributor Author

ysds commented Jan 8, 2026

Thanks for the feedback! I'll update this PR to use nested spreads instead of lodash.merge.

The approach would look like this:

const floatingUIOptions = useMemo<FloatingUIOptions>(
  () => ({
    ...props.floatingUIOptions, // Pass through other options
    useFloatingOptions: {
      open: show,
      onOpenChange: (open, _event, reason) => { ... },
      placement,
      middleware: [offset(10), shift(), flip()],
      ...props.floatingUIOptions?.useFloatingOptions, // User overrides
    },
    elementProps: {
      style: { zIndex: 40 },
      ...props.floatingUIOptions?.elementProps, // User overrides
    },
  }),
  [...]
);

Does this approach look good to you?

@nperez0111
Copy link
Contributor

Yep, exactly what I would expect @ysds

Use nested object spreads instead of lodash.merge to properly merge
floatingUIOptions properties. This prevents user-provided options like
`useFloatingOptions: { strategy: "fixed" }` from overwriting internal
settings such as `open`, `onOpenChange`, `placement`, and `middleware`.

Also fixes the type of floatingUIOptions in SuggestionMenuController
from UseFloatingOptions to FloatingUIOptions.

Closes TypeCellOS#2308
@ysds ysds force-pushed the fix/deep-merge-floatingUIOptions branch from 62bf888 to c61cae0 Compare January 10, 2026 17:01
@ysds
Copy link
Contributor Author

ysds commented Jan 10, 2026

Hi @nperez0111,
Updated to use nested object spreads instead of lodash.merge as you suggested. No new dependencies needed now.
Also fixed a type issue in SuggestionMenuController (UseFloatingOptionsFloatingUIOptions).

Copy link
Contributor

@nperez0111 nperez0111 left a comment

Choose a reason for hiding this comment

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

Fantastic @ysds, exactly what I'd have done myself

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 12, 2026

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/ariakit@2310

@blocknote/code-block

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/code-block@2310

@blocknote/core

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/core@2310

@blocknote/mantine

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/mantine@2310

@blocknote/react

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/react@2310

@blocknote/server-util

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/server-util@2310

@blocknote/shadcn

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/shadcn@2310

@blocknote/xl-ai

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-ai@2310

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-docx-exporter@2310

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-email-exporter@2310

@blocknote/xl-multi-column

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-multi-column@2310

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-odt-exporter@2310

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/TypeCellOS/BlockNote/@blocknote/xl-pdf-exporter@2310

commit: c61cae0

@nperez0111 nperez0111 merged commit 5160d73 into TypeCellOS:main Jan 12, 2026
8 of 11 checks passed
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.

floatingUIOptions.useFloatingOptions completely overwrites internal settings instead of merging

2 participants