mainmatter / ember-promise-modals Goto Github PK
View Code? Open in Web Editor NEWThe easy solution for rendering and handling modals in Ember.js apps. Promised.
Home Page: https://ember-promise-modals.com
License: MIT License
The easy solution for rendering and handling modals in Ember.js apps. Promised.
Home Page: https://ember-promise-modals.com
License: MIT License
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/ci.yml
actions/checkout v3
pnpm/action-setup v2.4.0
actions/setup-node v3
actions/checkout v3
pnpm/action-setup v2.4.0
actions/setup-node v3
actions/checkout v3
pnpm/action-setup v2.4.0
actions/setup-node v3
.github/workflows/deploy.yml
actions/checkout v3.6.0
JamesIves/github-pages-deploy-action v4.5.0
.github/workflows/release.yml
actions/checkout v3
actions/setup-node v3
package.json
@ember/test-waiters ^3.0.1
@embroider/util ^1.7.1
broccoli-funnel ^3.0.8
broccoli-merge-trees ^4.2.0
broccoli-postcss ^6.0.1
ember-auto-import ^2.4.2
ember-cli-babel ^7.26.11
ember-cli-htmlbars ^6.0.1
focus-trap ^6.9.3
postcss-preset-env ^7.6.0
@babel/eslint-parser 7.23.3
@ember/optional-features 2.0.0
@ember/string 3.1.1
@ember/test-helpers 2.9.4
@embroider/test-setup 3.0.3
@release-it-plugins/lerna-changelog 5.0.0
broccoli-asset-rev 3.0.0
ember-cli 4.12.2
ember-cli-dependency-checker 3.3.2
ember-cli-inject-live-reload 2.1.0
ember-cli-sri 2.1.1
ember-cli-terser 4.0.2
ember-disable-prototype-extensions 1.1.3
ember-load-initializers 2.1.2
ember-maybe-import-regenerator 1.0.0
ember-qunit 8.0.2
ember-resolver 8.1.0
ember-source 4.12.3
ember-source-channel-url 3.0.0
ember-template-lint 5.3.3
ember-try 2.0.0
eslint 8.55.0
eslint-config-prettier 8.10.0
eslint-plugin-ember 11.11.1
eslint-plugin-import-helpers 1.3.1
eslint-plugin-node 11.1.0
eslint-plugin-prettier 4.2.1
eslint-plugin-promise 6.1.1
eslint-plugin-qunit 7.3.4
loader.js 4.7.0
npm-run-all 4.1.5
prettier 2.8.8
qunit 2.20.0
qunit-console-grouper 0.3.0
qunit-dom 2.0.0
release-it 15.11.0
sinon 15.2.0
webpack 5.89.0
node 12.* || >= 16.*
.github/workflows/ci.yml
pnpm 8.11.0
The recent change to how the focus trap is set up (PR #549) is causing issues when you expect the close
action to return a value.
Specifically this change in the modal component on lines 103-105:
https://github.com/simplabs/ember-promise-modals/pull/549/files#diff-f1bdcfc6adc126290ecb2862332b13bf329fcd5a397b3ab6210de2911dc65d54L93-R105
Not passing in null here as it did before changes the behaviour in such a way that the focus trap's onDeactivate function calls closeModal again (without return value this time) and resolves the modal before the original @close
action call has a chance to resolve with the return value that was passed in.
So currently, this happens:
@close
@close
Reverting lines 103-105 linked above makes it work properly again, though that probably breaks something else that the PR fixed?
Another workaround might be to set onDeactivate to null through the open() call or globally on the modals service, but that feels like it shouldn't be necessary.
This way we could allow users to defer (parts of) rendering the content to keep the animations nice and smooth.
Hi!
@herzzanu and me have investigated a flaky test in a huge app.
After some frustrating investigation we have discovered, that the cause of test failures was that a modal's @close
callback was called twice.
The frustration was caused by trhee parts:
ember-concurrency
tasks threading through multiple components; a modal is opening a modal, etc;The specific error turned out to be "calling set on destroyed object", with stack trace pointing at this line:
https://github.com/mainmatter/ember-promise-modals/blob/v4.0.0/addon/components/modal.js#L148
The solution on our side was to make sure the modal was not being closed twice.
But I wonder, if this should even be a developer's concern? Why not let developers close the modal more than once?
At the very least, we could wrap the set
into if (!this.isDestroying && !this.isDestroyed)
. Or we could make the close
callback return early if it is called more than once.
Given we did so for most of our other projects, we might do it here as well.
When closing via click on the container, the modal gets "hidden" but stays in the DOM. This essentially disables all interaction with the application which then has to be reloaded to work again.
It does not always happen, but most of the time.
Screencast Chrome 102 Mac with the demo app:
https://user-images.githubusercontent.com/5049311/170370725-1b7b6ef4-29d7-467d-8e99-132d645e7fcb.mp4
I also did some debugging as in one project I often see timeouts in qunit tests with modals. It turned out that when a timeout happens, the event animationend
is not being triggered which leads to not calling modal._remove()
which leads to not resolving the promise. I am unsure if this is related or another problem.
Currently we immediately apply the focus-trap even if an animation is still about to happen. This may cause problems if something like an ember-tether is rendered inside the modal as the modal might still be moving.
This could be solved by utilizing the checkCanFocusTrap
hook: https://github.com/focus-trap/focus-trap#createoptions . We can pass it a promise that resolves once the animation is complete.
We might want similar behaviour when closing the modal
Error: testWaiter.endAsync called with no preceding testWaiter.beginAsync call.
Test waiter calls should always be paired. This can occur when a test waiter's paired calls are invoked in a non-deterministic order.
Hapens in a larger codebase with setupPromiseModals(hooks);
enabled. Needs further investigation.
We're currently running a fork of ember-promise-modals but it looks like most of our changes are now possible using the official addon. Our one remaining custom change is the addition of a beforeClose
modal option.
Our typical use-case for beforeClose
is when we have modal UI that allows user input, when that modal is closed if there are unsaved changes we want to abort the close and open another modal to get confirmation.
Simplified example:
setupController(controller, model) {
this.newsletterModal = this.modals.open(
EditNewsletterModal,
{newsletter: model},
{beforeClose: this.confirmUnsavedChanges}
);
}
async confirmUnsavedChanges() {
if (!this.model.hasDirtyAttributes) { return true; }
// result: true = close and discard, false = abort close, allow further edits and save
this.confirmModal = this.modals.open(ConfirmUnsavedChangesModal);
return this.confirmModal;
}
Does something like this sound like an appropriate addition? Is there something like this already available that I've missed?
Our implementation in the fork was very basic and can be seen in this commit.
Some addons like Ember Power Select render outside the component they're invoked in, making it impossible to use with EPM. (Although EPS can be forced to render in place, but could be difficult to deal with for various reasons). I saw no option in Focus Trap to exclude certain selectors.
I know it would reduce accesibility, but spending time with code that handle modals if we don't have EPM also takes away precious time we could otherwise spend with making our app more accessible.
It doesn't even have to be public API, just an option that's one would only use if really needed it.
Should I open a PR?
In theory it shuts down the 3rd of August 2021
https://github.blog/2021-04-29-goodbye-dependabot-preview-hello-dependabot/
Calling
close()
on the modal from the outside doesn't seem to close the modal if prefer-reduced-motion is enabled on the system and if that applies a 0s duration through CSS media queries. The modal elements are left in the DOM. If I set a non-0s duration, for example 0.01s, then it works.If however
close()
is called from inside the modal, then it works fine and the modal elements are removed from the DOM no matter what duration is used. With the 3.0.1 release it broke if you clicked the backdrop to close, but this seems to be fixed in themain
branch.So TLDR: A workaround seems to be to not set a 0s duration, such as 0.01s. Then everything works fine even with 3.0.1.
Originally posted by @bitwolfe in #665 (comment)
Unfortunately it seems this breaks installing this package from Git using Yarn Berry (at least v3.1.0 that I'm using) with nodeLinker: node-modules
. Yarn says "Unsupported workflow", as it's seems like it doesn't understand pnpm lockfiles yet..
Originally posted by @bitwolfe in #477 (comment)
We're already ember 4 compatible and implicitly testing against it through ember-release, ember-beta etc. but would be good to add 4.0.0 to the CI config explicitly.
We don't seem to have documentation explaining what the Modal instance can do (e.g. let modal = this.modals.open(...); modal.close()
).
Converting ember-promise-modals/modal
to a classic Ember Object would expand support to even earlier Ember versions. Huge codebases that struggle with updating could benefit greatly from EPM, and from what I observed, that part of the addon is not performance-critical.
We're patching EPM in our project at the moment. Do you accept PRs? :)
This happens on a PC in both Firefox and Chrome.
ESC
and the close button should both close the modal and return focus to the element that opened the modal.
ESC
and close the modal, the focus (correctly) returns to the button that opened the modal.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.