Skip to content

Commit

Permalink
fix(modal): make sure modal container is the same as UIkit container
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed May 1, 2023
1 parent 5b0b4bf commit 12caffe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addon/components/uk-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { guidFor } from "@ember/object/internals";
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";

import container from "ember-uikit/container";

function isBubbling(event) {
return event.target !== event.currentTarget;
}
Expand All @@ -27,7 +29,7 @@ export default class UkModal extends Component {
get containerSelector() {
// Only set the container to the default if no query string was passed as argument.
if (typeof this.args.container !== "string") {
return getOwner(this).rootElement || "body";
return container.selector ?? "body";
}

return this.args.container;
Expand Down
1 change: 1 addition & 0 deletions addon/container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { selector: null };
3 changes: 3 additions & 0 deletions addon/instance-initializers/uikit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { getOwner } from "@ember/application";
import UIkit from "uikit";

import container from "ember-uikit/container";

export function initialize(appInstance) {
// As there is only a single `Router` across the whole app, which is owned
// by the root `Application`, this reliably finds the root `Application`
Expand All @@ -9,6 +11,7 @@ export function initialize(appInstance) {
const hostApp = getOwner(appInstance.lookup("router:main"));

UIkit.container = hostApp.rootElement;
container.selector = hostApp.rootElement;
}

export default { initialize };

0 comments on commit 12caffe

Please sign in to comment.