atom-select-list
Advanced tools
Comparing version 0.7.1 to 0.7.2
{ | ||
"name": "atom-select-list", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "A general-purpose select list for use in Atom packages", | ||
@@ -5,0 +5,0 @@ "main": "./src/select-list-view.js", |
@@ -57,8 +57,8 @@ # atom-select-list | ||
* (Optional) `itemsClassList: [String]`: an array of strings that will be added as class names to the items element. | ||
* (Optional) `initialSelectionIndex: Number`: the index of the item to initially select and automatically select after query changes; defaults to 0. | ||
* (Optional) `initialSelectionIndex: Number`: the index of the item to initially select and automatically select after query changes; defaults to `0`. | ||
* (Optional) `didChangeQuery: (query: String) -> Void`: a function that is called when the query changes. | ||
* (Optional) `didChangeSelection: (item: Object) -> Void`: a function that is called when the selected item changes. | ||
* (Optional) `didConfirmSelection: (item: Object) -> Void`: a function that is called when the user clicks or presses enter on an item. | ||
* (Optional) `didConfirmSelection: (item: Object) -> Void`: a function that is called when the user clicks or presses <kbd>Enter</kbd> on an item. | ||
* (Optional) `didConfirmEmptySelection: () -> Void`: a function that is called when the user presses <kbd>Enter</kbd> but the list is empty. | ||
* (Optional) `didCancelSelection: () -> Void`: a function that is called when the user presses <kbd>Esc</kbd> or the list loses focus. | ||
* (Optional) `initiallyVisibleItemCount: Number`: When this options was provided, `SelectList` observe visibility of items in viewport, visibility state is passed as `visible` option to `elementForItem`. This is mainly used to skip heavy computation for invisible items. |
@@ -34,2 +34,13 @@ const {Disposable, CompositeDisposable, TextEditor} = require('atom') | ||
editorElement.addEventListener('blur', didLoseFocus) | ||
// When clicking the scrollbar of the items list, a blur event will be triggered | ||
// on the query editor element, but we don't want to treat that as a cancellation. | ||
// This mousedown listener allows us to detect this case and restore focus to the | ||
// query editor. This is based on https://stackoverflow.com/a/1480178. | ||
this.didClickItemsList = false | ||
this.element.addEventListener('mousedown', event => { | ||
if (event.target === this.refs.items) { | ||
this.didClickItemsList = true | ||
} | ||
}) | ||
this.disposables.add(new Disposable(() => { editorElement.removeEventListener('blur', didLoseFocus) })) | ||
@@ -58,3 +69,4 @@ } | ||
didLoseFocus (event) { | ||
if (this.element.contains(event.relatedTarget)) { | ||
if (this.didClickItemsList || this.element.contains(event.relatedTarget)) { | ||
this.didClickItemsList = false | ||
this.refs.queryEditor.element.focus() | ||
@@ -61,0 +73,0 @@ } else if (document.hasFocus()) { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
47890
5
1003