-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
fix: add functional HACK for triggering React change event #1182
Conversation
Hmm. This seems kinda odd to embed into this library for all Ember apps out of the box. 🤔 |
Instead of this, maybe you could leverage the hooks system?
See an example here: Note: this is still private API / hacks, but seems better to me than embedding things here... |
I think you'd basically do something like: import { _registerHook } from '@ember/test-helpers';
_registerHook('fillIn', 'start', (target: Target, text: string) => {
const tracker = target._valueTracker;
if (tracker) {
tracker.setValue('');
}
}); |
Great idea! Unfortunately, though, order matters when executing this hack, as you can see in facebook/react#11488 (comment). I attempted to implement this using both hooks ( Perhaps if we added a new Would that work? I'd be happy to submit a PR for the new hooks |
Ya, I think having a
Would that work? |
We could also add a |
Ah, sure, I could try something like that! I take it the PR I submitted is inadequate? If so, I can create a new one 🙂 |
It was a great starting point for the discussion here!! But yes, I think we probably are very unlikely to move forward with react support code directly living here... |
Closing in favour of #1185 |
Change
Add a functional hack when working with React-in-Ember apps or addons.
My team is using https://github.com/rewardops/ember-react-components (which is a modernization of https://github.com/alexlafroscia/ember-react-components) in order to bake React components into our Ember apps and addons. As you can see in the JSDoc in my changes, this hack is necessary for preparing React
<input />
elements forchange
events. Without this preparation,<input />
s ignore the simulated event followingfillIn
andtypeIn
actions.Further background on this issue can be read by following the links in the JSDoc. (Note that this a problem for folks in the Selenium ecosystem as well.)
Rationale
We realize that this addition to the
test-helpers
library is rather niche. Normally, we would have forked this library, published our own version and gone on our merry way. However, much of the Ember testing ecosystem (e.g., https://github.com/emberjs/ember-qunit, https://github.com/san650/ember-cli-page-object) presupposes the use of@ember/test-helpers
and has that dependency baked right in. As a result of this fairly tight coupling, leveraging our own forked (and renamed) library causes all sort of errors during testing, and so precludes us from going that direction — unless we also want to fork every other library that relies on this one.As a temporary measure, we've added a
tar.gz
pack in our forked repo (see https://github.com/rewardops/ember-test-helpers/releases/tag/v2.6.0), but we hope this is not a long-term solution. Instead, we're hoping that the fix we propose here is negligible enough to warrant inclusion in the origin library. We're certainly open to feedback! 🙂