Skip to content

Remove Popper.js and update components and tests to use floating-ui #263

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 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion lib/generators/ruby_ui/javascript_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def pin_tippy_js

inject_into_file Rails.root.join("config/importmap.rb"), <<~RUBY
pin "tippy.js", to: "https://cdn.jsdelivr.net/npm/[email protected]/+esm"
pin "@popperjs/core", to: "https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/+esm"\n
RUBY
end
end
Expand Down
12 changes: 1 addition & 11 deletions lib/ruby_ui/context_menu/context_menu_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ export default class extends Controller {
this.removeEventListeners();
this.deselectAll();
},
popperOptions: {
modifiers: [
{
name: "offset",
options: {
offset: [0, 4]
},
},
],
}
};

const mergedOptions = { ...this.optionsValue, ...defaultOptions };
Expand All @@ -62,7 +52,7 @@ export default class extends Controller {

setContentWidth(instance) {
// box-sizing: border-box
const content = instance.popper.querySelector('.tippy-content');
const content = this.tippy.popper.querySelector('.tippy-content');
if (content) {
content.style.width = `${instance.reference.offsetWidth}px`;
}
Expand Down
12 changes: 1 addition & 11 deletions lib/ruby_ui/hover_card/hover_card_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ export default class extends Controller {
this.removeEventListeners();
this.deselectAll();
},
popperOptions: {
modifiers: [
{
name: "offset",
options: {
offset: [0, 4]
},
},
],
}
};

const mergedOptions = { ...this.optionsValue, ...defaultOptions };
Expand All @@ -62,7 +52,7 @@ export default class extends Controller {

setContentWidth(instance) {
// box-sizing: border-box
const content = instance.popper.querySelector('.tippy-content');
const content = this.tippy.popper.querySelector('.tippy-content');
if (content) {
content.style.width = `${instance.reference.offsetWidth}px`;
}
Expand Down
4 changes: 4 additions & 0 deletions test/ruby_ui/context_menu_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ def test_render_with_all_items
end

assert_match(/Right click here/, output)
assert_match(/Back/, output)
assert_match(/Show Bookmarks Bar/, output)
assert_match(/Developer Tools/, output)
refute_match(/popper/i, output)
end
end
7 changes: 0 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@
hey-listen "^1.0.8"
tslib "^2.3.1"

"@popperjs/core@^2.9.0":
version "2.11.8"
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f"
integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==

chart.js@^4.4.1:
version "4.4.3"
resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-4.4.3.tgz#3b2e11e7010fefa99b07d0349236f5098e5226ad"
Expand Down Expand Up @@ -160,8 +155,6 @@ tippy.js@^6.3.7:
version "6.3.7"
resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-6.3.7.tgz#8ccfb651d642010ed9a32ff29b0e9e19c5b8c61c"
integrity sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ==
dependencies:
"@popperjs/core" "^2.9.0"

tslib@^2.3.1:
version "2.6.3"
Expand Down