Skip to content

Commit

Permalink
Fix more items indicator sometimes not appearing (#1086)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Oct 21, 2022
1 parent 4a6e2b0 commit 6853fac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 10 additions & 4 deletions app/components/object-inspector/sort-properties.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { map, sort } from '@ember/object/computed';
import Component from '@glimmer/component';
import { get, set, computed } from '@ember/object';
import { set, computed } from '@ember/object';
import { A } from '@ember/array';

export default class SortProperties extends Component {
@computed('args.properties')
get isArray() {
const props = A(this.args.properties || []);
return props.findBy('name', 'length') && props.findBy('name', 0);
return props.findBy('name', 'length') && props.findBy('name', '0');
}

/**
Expand All @@ -19,14 +19,20 @@ export default class SortProperties extends Component {
@computed('isArray', 'sorted.length')
get sortedProperties() {
// limit arrays
if (this.isArray && get(this, 'sorted.length') > 100) {
let props = A(this.sorted);
if (this.isArray) {
const item = props.findBy('name', 'length');
props.removeObject(item);
props.splice(0, 0, item);
}
if (this.isArray && this.sorted.length > 100) {
const indicator = {
name: '...',
value: {
inspect: 'there are more items, send to console to see all',
},
};
const props = this.sorted.slice(0, 100);
props = props.slice(0, 100);
props.push(indicator);
return props;
}
Expand Down
5 changes: 4 additions & 1 deletion ember_debug/object-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ export default DebugPort.extend({
}
this.sendMessage('updateProperty', {
objectId,
property: item.name,
property:
Array.isArray(object) && !Number.isNaN(parseInt(item.name))
? parseInt(item.name)
: item.name,
value,
mixinIndex,
dependentKeys,
Expand Down

0 comments on commit 6853fac

Please sign in to comment.