Skip to content

Commit 6f07a5e

Browse files
authored
Few minor fix (#1961)
* 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
1 parent 0488970 commit 6f07a5e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

docs/src/components/Examples/Plugins/SelectOnFocus.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default function SelectOnFocus() {
4646
</CodeBlock>
4747
<CodeBlock className="language-javascript" title="Javascript">
4848
{`$("#select-on-focus").selectize({
49-
plugins: ["restore_on_backspace"]
49+
plugins: ["select_on_focus"]
5050
});`}
5151
</CodeBlock>
5252
</div>

src/selectize.jquery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ $.fn.selectize = function (settings_user) {
9494
}
9595

9696
var option = readData($option) || {};
97-
option[field_label] = option[field_label] || $option.text();
9897
option[field_value] = option[field_value] || value;
98+
option[field_label] = option[field_label] || $option.text() || option[field_value];
9999
option[field_disabled] = option[field_disabled] || $option.prop('disabled');
100100
option[field_optgroup] = option[field_optgroup] || group;
101101
option.styles = $option.attr('style') || '';

src/selectize.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ $.extend(Selectize.prototype, {
423423
var defaultPrevented = e.isDefaultPrevented();
424424
var $target = $(e.target);
425425

426+
// prevent right click on option
427+
if (e.button && e.button === 2) {
428+
return;
429+
}
430+
426431
if (!self.isFocused) {
427432
// give control focus
428433
if (!defaultPrevented) {
@@ -751,6 +756,11 @@ $.extend(Selectize.prototype, {
751756
e.stopPropagation();
752757
}
753758

759+
// prevent right click on option
760+
if (e.button && e.button === 2) {
761+
return;
762+
}
763+
754764
$target = $(e.currentTarget);
755765
if ($target.hasClass('create')) {
756766
self.createItem(null, function() {

0 commit comments

Comments
 (0)