Skip to content

Commit

Permalink
Few minor fix (#1961)
Browse files Browse the repository at this point in the history
* fix: focus called twice / dropdown width

* fix: passing test, focus doesn't work

* fix: set position dropdown before is showing

* fix: const reasigned

* fix : doc spelling error

* fix: ignore right click on option

* fix: set text as value if text falsy
  • Loading branch information
fabienwnklr authored Jan 20, 2023
1 parent 0488970 commit 6f07a5e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/src/components/Examples/Plugins/SelectOnFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function SelectOnFocus() {
</CodeBlock>
<CodeBlock className="language-javascript" title="Javascript">
{`$("#select-on-focus").selectize({
plugins: ["restore_on_backspace"]
plugins: ["select_on_focus"]
});`}
</CodeBlock>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/selectize.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ $.fn.selectize = function (settings_user) {
}

var option = readData($option) || {};
option[field_label] = option[field_label] || $option.text();
option[field_value] = option[field_value] || value;
option[field_label] = option[field_label] || $option.text() || option[field_value];
option[field_disabled] = option[field_disabled] || $option.prop('disabled');
option[field_optgroup] = option[field_optgroup] || group;
option.styles = $option.attr('style') || '';
Expand Down
10 changes: 10 additions & 0 deletions src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ $.extend(Selectize.prototype, {
var defaultPrevented = e.isDefaultPrevented();
var $target = $(e.target);

// prevent right click on option
if (e.button && e.button === 2) {
return;
}

if (!self.isFocused) {
// give control focus
if (!defaultPrevented) {
Expand Down Expand Up @@ -751,6 +756,11 @@ $.extend(Selectize.prototype, {
e.stopPropagation();
}

// prevent right click on option
if (e.button && e.button === 2) {
return;
}

$target = $(e.currentTarget);
if ($target.hasClass('create')) {
self.createItem(null, function() {
Expand Down

0 comments on commit 6f07a5e

Please sign in to comment.