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 more items indicator sometimes not appearing #1086

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Copy link
Member

Choose a reason for hiding this comment

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

What is this doing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is to put the length property at the top, since otherwise it will be cutoff. Or it will look wierd at the end

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 @@ -331,7 +331,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