Skip to content
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 'firstObject/lastObject' properties in Ember 4 with native proxies #1726

Merged

Conversation

larry-x-yu
Copy link
Collaborator

@larry-x-yu larry-x-yu commented Feb 11, 2023

Root Cause Analysis
Ember 4.x replaced arrayContentDidChange with another function whereas the state of 'firstObject/lastObject' were left open.

What has changed

  • Added a test cases to reproduce the issue and verify the fix.

  • Fixed the issue by changing how firstObject and lastObject get its value.

Testing Done
yarn test passed locally.

@co-authored-by hjdivad

@larry-x-yu larry-x-yu marked this pull request as draft February 11, 2023 00:40
@larry-x-yu larry-x-yu changed the title Added a test case to reproduce the 'firstObject' issue Fix 'firstObject/lastObject' issue of BaseRecordArray caused by Ember 4.x Feb 13, 2023
@larry-x-yu larry-x-yu marked this pull request as ready for review February 13, 2023 18:55
@hjdivad hjdivad force-pushed the laryu/reproduce-first-object-issue branch 2 times, most recently from 7a2ee8f to 0a897d2 Compare February 15, 2023 21:00
Copy link
Collaborator

@hjdivad hjdivad left a comment

Choose a reason for hiding this comment

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

@larry-x-yu thanks for digging into this.

I pushed a couple changes

  • fixed the linting issues
  • changed the implementation to not rely on a heuristic
  • run the tests even for non-native proxies (since the test doesn't rely on knowing that implementation detail)

can you please expand the testing assuming the changes look good to you and then we can merge + release?

Larry Yu added 2 commits February 16, 2023 11:12
Rather than rely on the implementations from `MutableArray`, implement
these utility methods directly for the native proxy.
@hjdivad hjdivad force-pushed the laryu/reproduce-first-object-issue branch from ff0d36a to 85e9505 Compare February 16, 2023 19:13
@larry-x-yu larry-x-yu merged commit 378d2f9 into ember-m3:master Feb 16, 2023
@hjdivad hjdivad added the bug ch:bugfix label Feb 17, 2023
@hjdivad hjdivad changed the title Fix 'firstObject/lastObject' issue of BaseRecordArray caused by Ember 4.x Fix 'firstObject/lastObject' properties in Ember 4 with native proxies Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ch:bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants