Skip to content

Experimental/feature/remove flowbite#8953

Draft
tagliala wants to merge 2 commits intomasterfrom
experimental/feature/remove-flowbite
Draft

Experimental/feature/remove flowbite#8953
tagliala wants to merge 2 commits intomasterfrom
experimental/feature/remove-flowbite

Conversation

@tagliala
Copy link
Copy Markdown
Contributor

@tagliala tagliala commented Feb 25, 2026

Remove the Flowbite dependency (~80KB) and replace its three JS
components (dropdown, drawer, modal) with focused, minimal modules
that follow the existing Rails.delegate event delegation pattern.

Dropdown positioning uses @floating-ui/dom (~22KB vendored ESM).
Drawer and modal are pure JS with CSS transitions, no external
dependencies.

Data attributes are preserved (data-dropdown-toggle, data-drawer-show,
data-modal-show, data-modal-hide) for backward compatibility with
existing user templates and batch action partials.

Modal backdrop click is detected via event.target === activeModal
since the backdrop div sits behind the modal container in z-order.

  • Add app/javascript/active_admin/features/dropdown.js
  • Add app/javascript/active_admin/features/drawer.js
  • Add app/javascript/active_admin/features/modal.js
  • Vendor @floating-ui/dom@1.7.5 as self-contained ESM bundle
  • Remove flowbite from package.json, importmap, vendor, content scan
  • Update dependencies.rake to bundle @floating-ui/dom
  • Add features/javascript_components.feature with 7 @javascript scenarios
    covering dropdown, modal open/close, Escape key, and backdrop click
  • Add features/step_definitions/component_steps.rb with supporting steps

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.08%. Comparing base (8fb982f) to head (654570a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8953   +/-   ##
=======================================
  Coverage   99.08%   99.08%           
=======================================
  Files         139      140    +1     
  Lines        4046     4059   +13     
=======================================
+ Hits         4009     4022   +13     
  Misses         37       37           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch from e18afaa to e09b0c4 Compare February 25, 2026 17:11
@tagliala tagliala added the do not merge A PR will have a failed check until this label is removed label Feb 25, 2026
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

to be dropped

@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch from e09b0c4 to 707648f Compare February 25, 2026 17:14
@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch from 707648f to f1b9a55 Compare March 5, 2026 10:27
@tagliala tagliala marked this pull request as ready for review March 5, 2026 10:28
@tagliala tagliala marked this pull request as draft March 5, 2026 10:28
@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch from f1b9a55 to fcf631e Compare March 5, 2026 12:52
@tagliala tagliala requested a review from Copilot March 6, 2026 09:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the Flowbite dependency (~80KB) from Active Admin and replaces its three JS components (dropdown, drawer, modal) with focused, minimal modules using @floating-ui/dom (~22KB vendored ESM) for dropdown positioning and pure JS/CSS for drawer and modal. Data attributes are preserved for backward compatibility.

Changes:

  • Replace Flowbite with three new JS feature modules (dropdown.js, drawer.js, modal.js) and vendor @floating-ui/dom + @floating-ui/core ESM bundles
  • Remove all Flowbite-related dependencies from package.json, yarn.lock, config/importmap.rb, vendor/javascript/, and Tailwind content scanning
  • Add Cucumber feature tests and a planning document, and update documentation references

Reviewed changes

Copilot reviewed 14 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/javascript/active_admin/features/dropdown.js New dropdown module using Floating UI for positioning
app/javascript/active_admin/features/drawer.js New pure-JS drawer module with CSS transitions
app/javascript/active_admin/features/modal.js New pure-JS modal module with backdrop and Escape handling
app/javascript/active_admin.js Replace flowbite import with new feature module imports
vendor/javascript/@floating-ui--core.js Vendored ESM bundle for @floating-ui/core
vendor/javascript/@floating-ui--dom.js Vendored ESM bundle for @floating-ui/dom
vendor/javascript/floating-ui--dom.js Vendored UMD bundle (appears unused by importmap)
vendor/javascript/flowbite.js Deleted Flowbite vendor file
config/importmap.rb Replace flowbite pin with @floating-ui/core and @floating-ui/dom pins
package.json Replace flowbite dependency with @floating-ui/dom
yarn.lock Updated lockfile reflecting dependency changes
tasks/dependencies.rake Updated vendor task to copy floating-ui instead of flowbite
lib/generators/active_admin/assets/templates/tailwind.config.js Remove flowbite.js from Tailwind content scanning
features/javascript_components.feature New Cucumber feature with 7 scenarios for JS components
features/step_definitions/component_steps.rb New step definitions for component interaction
docs/plan-remove-flowbite.md Planning document for the Flowbite removal
UPGRADING.md Update batch action modal references
README.md Replace Flowbite credit with Floating UI
.github/copilot-instructions.md Update technology stack documentation

Comment thread tasks/dependencies.rake Outdated
Comment thread tasks/dependencies.rake
Comment on lines +161 to +174
## Summary of data attribute changes

| Current (Flowbite) | New (ActiveAdmin) | Component |
|---|---|---|
| `data-dropdown-toggle` | `data-aa-dropdown-toggle` | Dropdown |
| `data-dropdown-placement` | `data-aa-dropdown-placement` | Dropdown |
| `data-dropdown-offset-distance` | `data-aa-dropdown-offset` | Dropdown |
| `data-drawer-target` | `data-aa-drawer-target` | Drawer |
| `data-drawer-show` | `data-aa-drawer-show` | Drawer |
| `data-modal-target` | `data-aa-modal-target` | Modal |
| `data-modal-show` | `data-aa-modal-show` | Modal |
| `data-modal-hide` | `data-aa-modal-hide` | Modal |

> **Note**: Namespacing with `aa-` prevents conflicts with other libraries users may have. Alternatively, keep short names without prefix — decision needed.
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The plan document states that data attributes will be renamed with an aa- prefix (e.g., data-aa-dropdown-toggle, data-aa-modal-show), but the actual implementation keeps the original Flowbite attribute names (data-dropdown-toggle, data-modal-show, etc.) for backward compatibility. The "Summary of data attribute changes" table is now inaccurate and will confuse anyone reading this planning doc. Either update the table to reflect the decision to keep original names, or add a note that the aa- prefix was not adopted in favor of backward compatibility.

Copilot uses AI. Check for mistakes.
Comment thread features/javascript_components.feature
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

@tagliala I've opened a new pull request, #8961, to work on those changes. Once the pull request is ready, I'll request review from you.

@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch from e31e55a to 345a2b1 Compare March 6, 2026 23:16
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

@tagliala I've opened a new pull request, #8963, to work on those changes. Once the pull request is ready, I'll request review from you.

@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch 4 times, most recently from 1ba25c0 to c5fa716 Compare March 7, 2026 16:52
@tagliala tagliala requested a review from Copilot March 7, 2026 20:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated no new comments.

@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch 4 times, most recently from 96f1c7b to cf46523 Compare March 8, 2026 13:14
@tagliala tagliala requested a review from Copilot March 8, 2026 13:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated 1 comment.

}

const escapeKey = function(event) {
if (event.key === "Escape") { close() }
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

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

The escapeKey handler in drawer.js, modal.js, and dropdown.js all listen on document for keydown with event.key === "Escape". When a modal is open, pressing Escape will fire all three handlers — the modal closes, the drawer closes (if any), and the dropdown closes (if any). While these components are unlikely to be open simultaneously in normal usage, the lack of event.stopPropagation() or any coordination means a single Escape press leaks through all modules. This could matter if a modal were opened from within a dropdown action without first closing the dropdown. Consider having the modal and drawer escapeKey handlers call event.stopPropagation() (or at least check that their respective component is active before stopping propagation) to prevent unintended cascade.

Suggested change
if (event.key === "Escape") { close() }
if (!activeModal) { return }
if (event.key === "Escape") {
event.stopPropagation()
close()
}

Copilot uses AI. Check for mistakes.
@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch from cf46523 to d73214e Compare March 8, 2026 18:56
Remove the Flowbite dependency (~80KB) and replace its three JS
components (dropdown, drawer, modal) with focused, minimal modules
that follow the existing Rails.delegate event delegation pattern.

Dropdown positioning uses @floating-ui/dom (~22KB vendored ESM).
Drawer and modal are pure JS with CSS transitions, no external
dependencies.

Data attributes are preserved (data-dropdown-toggle, data-drawer-show,
data-modal-show, data-modal-hide) for backward compatibility with
existing user templates and batch action partials.

Modal backdrop click is detected via `event.target === activeModal`
since the backdrop div sits behind the modal container in z-order.

- Add app/javascript/active_admin/features/dropdown.js
- Add app/javascript/active_admin/features/drawer.js
- Add app/javascript/active_admin/features/modal.js
- Vendor @floating-ui/dom@1.7.5 as self-contained ESM bundle
- Remove flowbite from package.json, importmap, vendor, content scan
- Update dependencies.rake to bundle `@floating-ui/dom`
- Add features/javascript_components.feature with 7 @javascript scenarios
  covering dropdown, modal open/close, Escape key, and backdrop click
- Add features/step_definitions/component_steps.rb with supporting steps
@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch from d73214e to 6442b08 Compare March 8, 2026 18:57
drawer.setAttribute("aria-modal", "true")
drawer.setAttribute("role", "dialog")

document.body.classList.add("overflow-hidden", "xl:overflow-auto")
Copy link
Copy Markdown
Contributor Author

@tagliala tagliala Mar 8, 2026

Choose a reason for hiding this comment

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

Copilot:

Short answer: xl:overflow-auto applies overflow-auto only at the xl breakpoint and up, whereas applying overflow on the body would affect every viewport size. It's a responsive change to avoid global side-effects on smaller screens.

Why this is done (concise):

  • Breakpoint scope: xl:overflow-auto → only on extra‑large screens; body { overflow: auto } → always.
  • Prevents unwanted scroll behavior on mobile: a global body overflow can create double scrollbars or allow background scrolling when modals/drawers are shown.
  • Keeps smaller-screen UX native (touch/scroll) while enabling an internal scroller for large desktop layouts (e.g., fixed sidebars, content columns).
  • Helps contain scrollable regions (drawers, dropdowns, modals) to a specific layout at large widths without breaking responsive stacking at smaller widths.

I think this does not apply here, because we have a backdrop.

There is actually a difference in behavior, but it only happens if you are at small window size, you open the drawer, you resize the window to xl screen, you try to scroll

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated 2 comments.

Comment thread config/importmap.rb
Comment thread features/step_definitions/component_steps.rb
@tagliala tagliala force-pushed the experimental/feature/remove-flowbite branch from e11df66 to 654570a Compare March 8, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge A PR will have a failed check until this label is removed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants