Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions .github/workflows/docs.yml

This file was deleted.

9 changes: 5 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Guidance for coding agents working in this repo.
## What this is

`reactstrap` v10 (fork): stateless-ish React 19 components rendering Bootstrap 5 markup. No Bootstrap JS, no jQuery.
Positioning via `@popperjs/core`. Bootstrap 6 is out of scope (separate migration).
Positioning via Floating UI (`@floating-ui/react-dom`, `useFloating` called directly; no Popper). Bootstrap 6 is out of scope (separate migration).

## Stack

Expand Down Expand Up @@ -37,16 +37,17 @@ CI (`.github/workflows/ci.yml`) runs lint, format:check, typecheck, cover, build
- `src/index.ts` — the public barrel. Anything not exported here is internal.
- `src/utils.ts` — shared helpers and shared types (`CSSModule`, `Tag`, `Target`, `InnerRef`). Exposed as `Util`.
- `src/Transition.tsx` — internal replacement for `react-transition-group` (`Transition`, `useNodeRef`).
- `src/popper.tsx` — internal replacement for `react-popper` (`Manager`, `Reference`, `Popper`).
- `src/FloatingContent.tsx` — positioned tooltip/popover body; `DropdownMenu` floats against the toggle from `DropdownContext.reference`.
- `src/*Context.ts` — typed React contexts.
- `src/__tests__/*.spec.tsx` — Vitest specs; `typings.tsx` and `polymorphic.*.tsx` are compile-only type tests.
- `src/__mocks__/popper.tsx` — used via `vi.mock('../popper')`.
- `src/__tests__/setup.ts` spies `useFloating` (real implementation); assert options with `lastFloating()` / `middleware(name)` from `src/testUtils.tsx`.
- `stories/` — Storybook docs; `@conventioncatcorp/reactstrap` resolves to `src/index.ts` (tsconfig `paths` + Storybook alias).

## Conventions

- No `prop-types`, no `defaultProps` on function components (React 19 ignores them). Defaults live in destructuring.
Class components may keep `static defaultProps`; `PopperContent.defaultProps` is public API (apps patch `offset`).
Class components may keep `static defaultProps`; `FloatingContent.defaultProps` is public API (apps patch `offset`).
- `data-popper-placement` / `data-bs-popper` attributes are Bootstrap 5 CSS hooks, not Popper: keep them.
- No index signatures on props. Components with `tag`: `XOwnProps` + `XProps<T = default tag> = XOwnProps &
PolymorphicExtras<XOwnProps, T>` (spell `XOwnProps` out, or Storybook docgen loses the props table);
classes use `PolymorphicClassExtras` and `declare props: XProps<T>`. Add ok/`@ts-expect-error` cases to
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# 11.0.0 (unreleased)

Positioning moves from `@popperjs/core` (unmaintained since 2023) to [Floating UI](https://floating-ui.com/)
(`@floating-ui/react-dom`). Breaking:

- `PopperContent` → `FloatingContent` (`PopperContentProps` → `FloatingContentProps`). Patch defaults with
`FloatingContent.defaultProps.offset = 5`.
- `popperClassName` → `floatingClassName` (Tooltip, Popover, FloatingContent).
- `modifiers` → `middleware` (Floating UI middleware, run after the defaults; falsy entries are skipped). A
same-named entry replaces that default in place: `offset`, `flip`/`autoPlacement`, `shift`, `arrow` for
Tooltip/Popover/FloatingContent; `offset` (none by default), `flip`, `shift` for DropdownMenu. Popper's
`preventOverflow` is now `shift`.
- `offset: [skidding, distance]` → Floating UI `OffsetOptions`: `[0, 8]` becomes `8`, `[x, y]` becomes
`{ mainAxis: y, crossAxis: x }`. Popover defaults to `8`.
- `boundariesElement` → `boundary` (Floating UI `Boundary`, default `'clippingAncestors'`).
- `placement` / `strategy` use Floating UI types; `auto`, `auto-start` and `auto-end` still work (via `autoPlacement`,
which ignores `flip` and `fallbackPlacements`).
- Repositions on element resizes and layout shifts too (`autoUpdate`), not only scroll and window resize. `shift` keeps
the element tethered to its target, like Popper's `preventOverflow`.
- Removed: `data-popper-reference-hidden` attribute, `Util.PopperPlacements`.
- Fixes: `DropdownToggle` `innerRef` now works inside a navbar (and when swapped); a positioned `DropdownMenu` no
longer drops its `onClick`.

# 10.0.0 (2026-11-10)

First release of `@conventioncatcorp/reactstrap`, the ConventionCatCorp fork. TypeScript, React 19 and Bootstrap 5
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ These libraries are not bundled with Reactstrap and required at runtime:

## About the Project

This library contains React Bootstrap components that favor composition and control. The library does not depend on jQuery or Bootstrap javascript. However, [Popper](https://popper.js.org/) (`@popperjs/core`) is relied upon for advanced positioning of content like Tooltips, Popovers, and auto-flipping Dropdowns.
This library contains React Bootstrap components that favor composition and control. The library does not depend on jQuery or Bootstrap javascript. However, [Floating UI](https://floating-ui.com/) (`@floating-ui/react-dom`) is relied upon for advanced positioning of content like Tooltips, Popovers, and auto-flipping Dropdowns.

There are a few core concepts to understand in order to make the most out of this library.

Expand Down Expand Up @@ -94,7 +94,7 @@ There are a few core concepts to understand in order to make the most out of thi

## Documentation

Storybook docs are deployed to this repo's GitHub Pages by `.github/workflows/docs.yml` (`npm start` locally).
Storybook docs are not hosted; run them locally with `npm start`.
Upstream v9 docs: https://reactstrap.github.io

## [Contributing](CONTRIBUTING.md)
Expand Down Expand Up @@ -124,8 +124,6 @@ npm publish # prepublishOnly runs typecheck, lint, tests a
git push --follow-tags
```

Storybook docs deploy to GitHub Pages on every push to `master`.

## In the wild

Organizations and projects using `reactstrap`
Expand Down
53 changes: 45 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
}
},
"dependencies": {
"@popperjs/core": "^2.11.8",
"@floating-ui/react-dom": "^2.1.9",
"classnames": "^2.5.1"
},
"peerDependencies": {
Expand Down
39 changes: 19 additions & 20 deletions src/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
type SyntheticEvent,
} from 'react';
import classNames from 'classnames';
import { Manager } from './popper';
import {
DropdownContext,
type DropdownContextValue,
Expand Down Expand Up @@ -52,7 +51,7 @@ export interface DropdownOwnProps {
cssModule?: CSSModule;
/** Shorthand for `direction="up"` (only when direction is `down`). */
dropup?: boolean;
/** Render the menu without popper (static positioning). */
/** Render the menu statically (no floating positioning). */
inNavbar?: boolean;
/** Add `.active` when an item of the second child (the menu) is active. */
setActiveFromChild?: boolean;
Expand Down Expand Up @@ -107,13 +106,15 @@ function keyCodeOf(e: { which: number; key?: string }): number {
}

class Dropdown<T extends ElementType = 'div'> extends Component<
DropdownProps<T>
DropdownProps<T>,
{ reference: HTMLElement | null }
> {
// Not `Readonly<P>`: lets JSX infer `T` from a string `tag` (else it widens to `ElementType`).
declare props: DropdownProps<T>;
static override contextType = InputGroupContext;
declare context: ContextType<typeof InputGroupContext>;

override state = { reference: null as HTMLElement | null };
containerRef = createRef<HTMLElement>();
menuRef = createRef<HTMLElement>();
toggleRef = createRef<HTMLElement>();
Expand All @@ -137,6 +138,7 @@ class Dropdown<T extends ElementType = 'div'> extends Component<

handleToggleRef = (el: HTMLElement | null) => {
this.toggleRef.current = el;
if (el !== this.state.reference) this.setState({ reference: el });
};

handleDocumentClick = (e: Event) => {
Expand Down Expand Up @@ -259,6 +261,7 @@ class Dropdown<T extends ElementType = 'div'> extends Component<
// Called by DropdownMenu with its DOM node
onMenuRef: this.handleMenuRef,
onToggleRef: this.handleToggleRef,
reference: this.state.reference,
menuRole: this.props.menuRole,
};
}
Expand Down Expand Up @@ -355,29 +358,25 @@ class Dropdown<T extends ElementType = 'div'> extends Component<
if (this.context.insideInputGroup) {
return (
<DropdownContext.Provider value={this.getContextValue()}>
<Manager>
{Children.map(this.props.children, (child) =>
cloneElement(child as ReactElement<any>, {
onKeyDown: this.handleKeyDown,
}),
)}
</Manager>
{Children.map(this.props.children, (child) =>
cloneElement(child as ReactElement<any>, {
onKeyDown: this.handleKeyDown,
}),
)}
</DropdownContext.Provider>
);
}

return (
<DropdownContext.Provider value={this.getContextValue()}>
<Manager>
<Tag
{...attrs}
{...{
[typeof Tag === 'string' ? 'ref' : 'innerRef']: this.containerRef,
}}
onKeyDown={this.handleKeyDown}
className={classes}
/>
</Manager>
<Tag
{...attrs}
{...{
[typeof Tag === 'string' ? 'ref' : 'innerRef']: this.containerRef,
}}
onKeyDown={this.handleKeyDown}
className={classes}
/>
</DropdownContext.Provider>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/DropdownContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface DropdownContextValue {
/** DropdownMenu reports its DOM node, so outside clicks close the dropdown. */
onMenuRef?: (el: HTMLElement | null) => void;
onToggleRef?: (el: HTMLElement | null) => void;
/** The toggle's DOM node; DropdownMenu floats against it. */
reference?: HTMLElement | null;
menuRole?: 'listbox' | 'menu' | boolean;
}

Expand Down
Loading
Loading