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

Update ember-in-viewport, ember-wormhole, move ember-composable-helpers to devDependencies #693

Merged
merged 10 commits into from
May 26, 2019

Conversation

fran-worley
Copy link
Contributor

@fran-worley fran-worley commented May 21, 2019

Suggesting this PR in favour of:
#674
#682

@alexander-alvarez I can't see a way around the api change here with the ember-in-viewport event unless @snewcomer can think of one. I'm not sure if it's specifically an issue with changes to ember-in-viewport or a combination of that and newer emberjs but without this change we were getting Uncaught TypeError: inViewport.startIntersectionObserver is not a function as I assume the mixin was trying to call startIntersectionObserver on our action/ function rather than the imported service.

@snewcomer any ideas why our onScrollToBottom test is now only being hit 3 times. I'm not entirely sure the justification behind it being hit 4 times in the first place...

@snewcomer
Copy link
Collaborator

Looks good! On that test, the onScrollToBottom doesn't look like it is being hit. Perhaps instead of the scrollTo helper, you could try something like this. scrollIntoView

https://github.com/ember-infinity/ember-infinity/blob/master/tests/acceptance/infinity-route-test.js#L28

@fran-worley
Copy link
Contributor Author

@snewcomer that unfortunately doesn't seem to have improved things. I've updated the scrolling tests here - https://github.com/offirgolan/ember-light-table/tree/scrolling-tests not to use ember-native-dom-helpers and the tests in question pass prior to updating ember inViewport but not afterwards... 😢

@fran-worley
Copy link
Contributor Author

@snewcomer the failings are definitely related to a change in ember-in-viewport between 3.0 and 3.1 I've run some tests locally and I can get everything passing (even with the breaking change to inViewport event name) at v3.0.3 but the onScrollToBottom failures reappear as soon as ember-in-viewport is updated any ideas what changed that could be causing the issue?

Oddly the dummy app seems to have the opposite problem and after upgrading ember-in-viewport onScrollToBottom is called continuously without actually doing any scrolling at all:

image

@snewcomer
Copy link
Collaborator

snewcomer commented May 24, 2019

@fran-worley The infinite loop seems to be b/c of the observer on scheduleScrolledToBottom. We need to remove rows.[]. Second, there are three things I identified to change -

  1. Upgrade to 3.5.8 ember-in-viewport
  2. change lt-infinity.js
import Component from '@ember/component';
import layout from '../templates/components/lt-infinity';
import { get } from '@ember/object';
import { inject as service } from '@ember/service';

export default Component.extend({
  layout,

  inViewport: service(),

  tagName: '',

  rows: null,
  scrollableContent: null,

  didInsertElement() {
    this._super(...arguments);

    let scrollBuffer = this.get('scrollBuffer');
    let scrollableContent = this.get('scrollableContent');

    const options = {
      viewportSpy: true,
      viewportTolerance: {
        bottom: scrollBuffer
      },
      scrollableArea: scrollableContent
    };

    const { onEnter, onExit } = this.inViewport.watchElement(document.querySelector('.lt-infinity'), options);
    onEnter(this.didEnterViewport.bind(this));
    onExit(this.didExitViewport.bind(this));
  },

  didEnterViewport() {
    get(this, 'enterViewport')();
  },

  didExitViewport() {
    get(this, 'exitViewport')();
  }
});
  1. add to lt-infinity.hbs
<div class="lt-infinity"></div>

Lastly there is a bug b/c the "sentinel" (lt-infinity) gets new properties and breaks the cache. So the above won't work until I fix an underlying library and bump in-viewport to 3.5.8

@snewcomer
Copy link
Collaborator

@fran-worley If you update ember-in-viewport to 3.5.8 as well as the above changes, this should work. Just tested! 👍

@fran-worley
Copy link
Contributor Author

You are a genius! I'll take a look at this in the morning and see if we can get a passing build 👯

@fran-worley
Copy link
Contributor Author

@snewcomer So I've revised the code as per your suggestions with a few tweaks to get things to pass:

  1. I added the watch cleanup on destroy as we started getting lots of errors trying to set properties on destroyed objects and seemed sensible.

  2. Reverted the changes to the lt-infinity element (tagName, classNames and hbs template) as (a) your example would run into issues where there is more than one light table in the document and any attempt to select the specific element caused TypeError: Invalid value used as weak map key all over the place. Reverting seemed simpler and to work.

  3. I've dropped the lt-infinity rows property as I can't see that we use it anywhere, it wasn't documented, tests still pass without it and dummy app renders fine.

Final thoughts on the changes to ember-in-viewport integration @alexander-alvarez and @snewcomer ?:

  1. in dropping the mixin we no longer have a classNameBinding for 'viewportEntered:in-viewport' We didn't use this internally and I can't see it being documented but it is possible that people have been using it. Should we recreate this class to avoid the breaking change?

  2. Now that we're not using the mixin and are importing the service ourselves we could revert the breaking change to rename the closure action inViewport => enterViewport . I'm in favour of keeping it but we could now deprecate it nicely I suppose. Another option would be to revert the change to the lt-body component (which is documented) but leave it in lt-infinity which is not documented.

@snewcomer
Copy link
Collaborator

@fran-worley Very nice work! We can keep the inViewport action if we rename the service. Something like inViewportService: service('in-viewport'). Not using the template is ok too! If you found a reason you needed it, we would need something like this.

Otherwise looks great!

@fran-worley fran-worley changed the title Update dependencies Update ember-in-viewport, ember-wormhole, move ember-composable-helpers to devDependencies May 26, 2019
@fran-worley
Copy link
Contributor Author

@alexander-alvarez , @snewcomer I believe this PR is ready to go. I'm going to raise a new one to update Ember cli etc to avoid the div getting too big.

I've added a deprecation warning to anyone using the inViewport event on lt-body component as this event is included in the current docs. I don't consider the changes to the lt-infinity component breaking as this component isn't documented and is therefore purely internal. Happy to revise if you think best.

Copy link
Collaborator

@snewcomer snewcomer left a comment

Choose a reason for hiding this comment

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

Great work @fran-worley! Just for perpetuity sake, the bug here was in ember-in-viewport and not property "exiting" with a scrollable container defined.

Also if you wanted to avoid the deprecation, you could rename the service injection to inViewportService. Otherwise, 👍

Copy link
Collaborator

@snewcomer snewcomer left a comment

Choose a reason for hiding this comment

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

just for thoughts

addon/components/lt-infinity.js Show resolved Hide resolved
addon/components/lt-infinity.js Show resolved Hide resolved
@fran-worley
Copy link
Contributor Author

@snewcomer IMHO the deprecation to rename the action/event is better:

  1. grammatically enterViewport and exitViewport are nicer than inViewport and exitViewport
  2. We've already seen how people can unexpectedly run into issues because of the name overlap here - which you can probably close once this is merged!

@adong
Copy link

adong commented Aug 13, 2020

--scheduleScrolledToBottom: observer('rows.[]', 'isInViewport', function() {	  
++scheduleScrolledToBottom: observer('isInViewport', function() {

It indeed broke our existing functionality.

Ref: screwdriver-cd/screwdriver#2181 (comment)


Let me illustrate an use case that no longer worked

With rows.[], the following sequence would occur if we load 5 items at a time inside onScrolledToBottom=(action "onScrolledToBottom")

Assuming we have 10 rows in our view-port:

header
---
.
.
.
.
.
.
.
.
.
.

First time, it loads 5

header
---
row1
row2
row3
row4
row5
.
.
.
.
.

Because rows.[] changed from 0 to 5, it will continue to call and push lt-infinity out of the view-port

So we end up here, and even though rows.[] will increase 1 more time, but since its out of view-port, it will stop calling onScrolledToBottom

header
---
row1
row2
row3
row4
row5
row6
row7
row8
row9
row10

This PR removes computed property dependencies of rows.[], and broke such flow.


Hmm, or 🤔 maybe I'm using it wrong.

RobbieTheWagner added a commit that referenced this pull request Feb 9, 2021
* replace `sendAction` with modern callable methods

* make easy jquery fixes

* Release v2.0.0-beta.0

* Release v2.0.0-beta.1

* removed jquery

* yarn upgrade

* Update ember-scrollable

* Assert and Test compatibility with LTS 3.4

* Officially drop support for node 4 in package.json

* bump vertical-collection to v1.0.0-beta.13

* Replace merge with assign (#673)

* bump vertical-collection to v1.0.0-beta.13

* replace merge with assign

* ensure ember-scrollable updates when rows are updated (#677)

* refactor: Remove sendAction() calls (#686)

* release 2.0.0-beta.3

* Replace propertyWillChange/propertyDidChange with notifyPropertyChange and add polyfill for < Ember 3.1 (#692)

Fixes #660

* update changelog for 2.x

* Update ember-in-viewport, ember-wormhole, move ember-composable-helpers to devDependencies (#693)

* move ember composable helpers to dev dependencies and bump version  see #524

* bump ember wormhole

* add ember lts 3.8 to travis

* remove ember-native-dom-helpers testing add-on

* update multiple table test from 1-x branch to remove native-dom-helpers add-on

* [breaking] rename inViewport closure action to enterViewport

paving the way to update ember-in-viewport dependency

* fixes infinite loop on onScrolledToBottom

* remove unused rows property from lt-infinity

* bump ember-in-viewport version and refactor lt-infinity component not to use mixin

* make lt-body.inViewport event deprecated in favour of enterViewport and test

* Drop node 6 support as end of line Apr 2019 (#698)

LGTM! Node 8 it latest Maintenance LTS and will be EOL in December

* Bump Ember CLI to 3.8 and update other dependencies (#696)

* bump ember cli to lts 3.8 update other dev dependencies

also apply some ember add-on blueprint changes

* fix handlebar lint errors

Note - unsure why 'no-inline-styles' config isn’t being applied. For now I’ve manually disabled the rule in applicable templates

* disable js no-observer rule

* update eslint-plugin-ember-suave and fix lint errors

* upgrade ember-mirage (used for dummy app)

* upgrade remaining addons

* set minimum supported ember version at 2.18 (#700)

see community survey results - https://emberjs.com/ember-community-survey-2019/

* migrate to using lerna-changelog (#697)

* update changelog [ci skip]

* BREAKING drop support for ember 2.18 (#713)

* [BREAKING] drop support for ember 2.18

* fix travis - ember release can fail

* as we use the compute helper we need to restore ember-composable-helpers as a dependency (#714)

* [BREAKING] fixes #444 #662 converts ES6 native classes to ember objects (#701)

This is a breaking change as it converts the new Class() syntax to Class.create().
In addition, the only way I could get these to work was to convert the positional arguments to named args in an options hashes:

`new Table(columns, rows)` => `Table.create(columns: columns, rows: rows)`
`new Row(content, options)` => `Row.create({ content: })`
`new Column(opts)` => `Column.create(opts)`

We’ve had to replace the native constructor methods with emberObject init methods as per the official docs which should also fix #699. As a result we’ve removed the Ember 2.12 ‘hacks’ which shouldn’t be an issue as we’ve bumped ember version minimum version to 2.18.

* Bump to ember cli 3.12 and update dependencies (#716)

* bump addons

* update ember cli to 3.12

* drop ember-release from allowed travis failures

* use yarn not npm and remove unused ember-cli-changelog

* update ember changelog

* [ci skip] fix dummy app port following update to ember cli 3.12

see ember-cli/ember-cli#8794

* release v2.0.0-beta.4

* [ci-skip] update changelog for beta 4 release

* replace volatile computed properties with native getters (#718)

* Add a guard to check if scaffolding cells exist

* Always render scaffolding row in table header

* Test lt-scaffolding-row

* Update ember-scrollable version to jquery-less

* bump ember-code-snippet for dummy app

* update travis to include recent LTS versions of ember

* fix lint issues

* bump ember cli to 3.16.1 and fix/ warn easy js lint errors disable other rules

* bump dependency addons

* [ci skip] bump changelog and yuidoc addons

* [ci-skip] update changelog

* fix deprecation warning for overridden rowspan cp

* remove unsafe style attribute warnings

* make compute own helper then drop ember-composable-helpers as dependency

* Remove debugging line in compute helper

* Drop support to Ember 3.4 and 3.5

Related #739

* add testing for ember 3.20

* bump addons

* drop ember-suave eslint to fix travis

# Conflicts:
#	package.json
#	yarn.lock

* [ci-skip] update ember version in readme

* v3.16.1...v3.20.0

* drop support for ember <3.12

* drop this.get

Co-authored-by: Donald Wasserman <[email protected]>
Co-authored-by: Alex Alvarez <[email protected]>
Co-authored-by: Gaurav Munjal <[email protected]>
Co-authored-by: Fran Worley <[email protected]>
Co-authored-by: Michal Bryxí <[email protected]>
Co-authored-by: mmadsen2 <[email protected]>
Co-authored-by: Tomasz Węgrzyn <[email protected]>
Co-authored-by: Richard Viney <[email protected]>
Co-authored-by: gorzas <[email protected]>
RobbieTheWagner added a commit that referenced this pull request Jul 8, 2022
* replace `sendAction` with modern callable methods

* make easy jquery fixes

* Release v2.0.0-beta.0

* Release v2.0.0-beta.1

* removed jquery

* yarn upgrade

* Update ember-scrollable

* Assert and Test compatibility with LTS 3.4

* Officially drop support for node 4 in package.json

* bump vertical-collection to v1.0.0-beta.13

* Replace merge with assign (#673)

* bump vertical-collection to v1.0.0-beta.13

* replace merge with assign

* ensure ember-scrollable updates when rows are updated (#677)

* refactor: Remove sendAction() calls (#686)

* release 2.0.0-beta.3

* Replace propertyWillChange/propertyDidChange with notifyPropertyChange and add polyfill for < Ember 3.1 (#692)

Fixes #660

* update changelog for 2.x

* Update ember-in-viewport, ember-wormhole, move ember-composable-helpers to devDependencies (#693)

* move ember composable helpers to dev dependencies and bump version  see #524

* bump ember wormhole

* add ember lts 3.8 to travis

* remove ember-native-dom-helpers testing add-on

* update multiple table test from 1-x branch to remove native-dom-helpers add-on

* [breaking] rename inViewport closure action to enterViewport

paving the way to update ember-in-viewport dependency

* fixes infinite loop on onScrolledToBottom

* remove unused rows property from lt-infinity

* bump ember-in-viewport version and refactor lt-infinity component not to use mixin

* make lt-body.inViewport event deprecated in favour of enterViewport and test

* Drop node 6 support as end of line Apr 2019 (#698)

LGTM! Node 8 it latest Maintenance LTS and will be EOL in December

* Bump Ember CLI to 3.8 and update other dependencies (#696)

* bump ember cli to lts 3.8 update other dev dependencies

also apply some ember add-on blueprint changes

* fix handlebar lint errors

Note - unsure why 'no-inline-styles' config isn’t being applied. For now I’ve manually disabled the rule in applicable templates

* disable js no-observer rule

* update eslint-plugin-ember-suave and fix lint errors

* upgrade ember-mirage (used for dummy app)

* upgrade remaining addons

* set minimum supported ember version at 2.18 (#700)

see community survey results - https://emberjs.com/ember-community-survey-2019/

* migrate to using lerna-changelog (#697)

* update changelog [ci skip]

* BREAKING drop support for ember 2.18 (#713)

* [BREAKING] drop support for ember 2.18

* fix travis - ember release can fail

* as we use the compute helper we need to restore ember-composable-helpers as a dependency (#714)

* [BREAKING] fixes #444 #662 converts ES6 native classes to ember objects (#701)

This is a breaking change as it converts the new Class() syntax to Class.create().
In addition, the only way I could get these to work was to convert the positional arguments to named args in an options hashes:

`new Table(columns, rows)` => `Table.create(columns: columns, rows: rows)`
`new Row(content, options)` => `Row.create({ content: })`
`new Column(opts)` => `Column.create(opts)`

We’ve had to replace the native constructor methods with emberObject init methods as per the official docs which should also fix #699. As a result we’ve removed the Ember 2.12 ‘hacks’ which shouldn’t be an issue as we’ve bumped ember version minimum version to 2.18.

* Bump to ember cli 3.12 and update dependencies (#716)

* bump addons

* update ember cli to 3.12

* drop ember-release from allowed travis failures

* use yarn not npm and remove unused ember-cli-changelog

* update ember changelog

* [ci skip] fix dummy app port following update to ember cli 3.12

see ember-cli/ember-cli#8794

* release v2.0.0-beta.4

* [ci-skip] update changelog for beta 4 release

* replace volatile computed properties with native getters (#718)

* Add a guard to check if scaffolding cells exist

* Always render scaffolding row in table header

* Test lt-scaffolding-row

* Update ember-scrollable version to jquery-less

* bump ember-code-snippet for dummy app

* update travis to include recent LTS versions of ember

* fix lint issues

* bump ember cli to 3.16.1 and fix/ warn easy js lint errors disable other rules

* bump dependency addons

* [ci skip] bump changelog and yuidoc addons

* [ci-skip] update changelog

* fix deprecation warning for overridden rowspan cp

* remove unsafe style attribute warnings

* make compute own helper then drop ember-composable-helpers as dependency

* Remove debugging line in compute helper

* Drop support to Ember 3.4 and 3.5

Related #739

* add testing for ember 3.20

* correct travis

* bump addons

* v3.16.1...v3.20.0

* bump ember version to 3.20

* fix travis.yml

* fix eslintrc

* replace one-way-controls with ember-power-select and ember input

* convert to angle bracket syntax

* fix ember data deprecations

* fix ember-power-select commit

* replace actions for fn/on non shared table

* replace table-shared mixin with base-table component

* convert action to fn for base-table actions

* replace remainder of action with on/fn

* bump dummy app addons

* Drop support to Ember 3.4 and 3.5

Related #739

* add testing for ember 3.20

* bump addons

* drop ember-suave eslint to fix travis

# Conflicts:
#	package.json
#	yarn.lock

* [ci-skip] update ember version in readme

* v3.16.1...v3.20.0

* drop support for ember <3.12

* drop this.get

* Released 3.0.0-beta.0

* ci: Add github actions with embroider test scenarios

* build: Drop Ember 3.12 support

BREAKING CHANGE: Dropped support for Ember 3.12

* Node 12

* fix: Fix linting errors

* ci: Allow embroider tests to fail

Tests pass locally but not in when running with GitHub actions

* docs: Remove Embroider safe and optimized from readme

CI fails in GitHub actions

* fix: Change to @faker/fakerjs to fix missing avatars

* Revert "fix: Change to @faker/fakerjs to fix missing avatars"

@faker/fakerjs requires Node 14. This reverts commit 81ba515.

Co-authored-by: Donald Wasserman <[email protected]>
Co-authored-by: Alex Alvarez <[email protected]>
Co-authored-by: Gaurav Munjal <[email protected]>
Co-authored-by: Fran Worley <[email protected]>
Co-authored-by: Michal Bryxí <[email protected]>
Co-authored-by: mmadsen2 <[email protected]>
Co-authored-by: Tomasz Węgrzyn <[email protected]>
Co-authored-by: Richard Viney <[email protected]>
Co-authored-by: gorzas <[email protected]>
Co-authored-by: maxwondercorn <[email protected]>
Co-authored-by: Robert Wagner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants