atom-select-list
Advanced tools
Comparing version 0.4.0 to 0.5.0
{ | ||
"name": "atom-select-list", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "A general-purpose select list for use in Atom packages", | ||
@@ -5,0 +5,0 @@ "main": "./src/select-list-view.js", |
@@ -45,2 +45,3 @@ # atom-select-list | ||
* (Optional) `query: String`: a string that will replace the contents of the query editor. | ||
* (Optional) `selectQuery: Boolean`: a boolean indicating whether the query text should be selected or not. | ||
* (Optional) `order: (item1: Object, item2: Object) -> Number`: a function that allows to change the order in which items are shown. | ||
@@ -47,0 +48,0 @@ * (Optional) `emptyMessage: String`: a string shown when the list is empty. |
@@ -114,2 +114,10 @@ const {Disposable, CompositeDisposable, TextEditor} = require('atom') | ||
if (props.hasOwnProperty('selectQuery')) { | ||
if (props.selectQuery) { | ||
this.refs.queryEditor.selectAll() | ||
} else { | ||
this.refs.queryEditor.clearSelections() | ||
} | ||
} | ||
if (props.hasOwnProperty('order')) { | ||
@@ -116,0 +124,0 @@ this.props.order = props.order |
@@ -510,2 +510,25 @@ /** @babel */ | ||
}) | ||
it('changing and selecting the query', async () => { | ||
let selectListView = new SelectListView({ | ||
itemsClassList: [], items: [], | ||
elementForItem: (i) => document.createElement('li') | ||
}) | ||
await selectListView.update({query: 'test q'}) | ||
assert.equal(selectListView.getQuery(), 'test q') | ||
assert.equal(selectListView.refs.queryEditor.getSelectedText(), '') | ||
await selectListView.update({query: 'test q2', selectQuery: true}) | ||
assert.equal(selectListView.getQuery(), 'test q2') | ||
assert.equal(selectListView.refs.queryEditor.getSelectedText(), 'test q2') | ||
await selectListView.update({query: 'test q3', selectQuery: false}) | ||
assert.equal(selectListView.getQuery(), 'test q3') | ||
assert.equal(selectListView.refs.queryEditor.getSelectedText(), '') | ||
await selectListView.update({selectQuery: true}) | ||
assert.equal(selectListView.getQuery(), 'test q3') | ||
assert.equal(selectListView.refs.queryEditor.getSelectedText(), 'test q3') | ||
}) | ||
}) | ||
@@ -512,0 +535,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38623
819
59