Skip to content

Commit

Permalink
Close #3925. Update selectInput's binding to use selectize.js' getVal…
Browse files Browse the repository at this point in the history
…ue() method when relevant
  • Loading branch information
cpsievert committed Oct 26, 2023
1 parent 81bdde6 commit 134d2a0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
7 changes: 6 additions & 1 deletion inst/www/shared/shiny.js
Original file line number Diff line number Diff line change
Expand Up @@ -9253,7 +9253,12 @@
}, {
key: "getValue",
value: function getValue(el) {
return (0, import_jquery15.default)(el).val();
if (!isSelectize(el)) {
return (0, import_jquery15.default)(el).val();
} else {
var selectize = this._selectize(el);
return selectize === null || selectize === void 0 ? void 0 : selectize.getValue();
}
}
}, {
key: "setValue",
Expand Down
4 changes: 2 additions & 2 deletions inst/www/shared/shiny.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/www/shared/shiny.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/www/shared/shiny.min.js.map

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions srcts/src/bindings/input/selectInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { InputBinding } from "./inputBinding";
import { $escape, hasDefinedProperty, updateLabel } from "../../utils";
import { indirectEval } from "../../utils/eval";
import { shinyBindAll, shinyUnbindAll } from "../../shiny/initedMethods";
import type { NotUndefined } from "../../utils/extraTypes";

type SelectHTMLElement = HTMLSelectElement & { nonempty: boolean };

Expand Down Expand Up @@ -62,10 +61,14 @@ class SelectInputBinding extends InputBinding {
getId(el: SelectHTMLElement): string {
return InputBinding.prototype.getId.call(this, el) || el.name;
}
getValue(
el: HTMLElement
): NotUndefined<ReturnType<JQuery<HTMLElement>["val"]>> {
return $(el).val() as NotUndefined<ReturnType<JQuery<HTMLElement>["val"]>>;
getValue(el: SelectHTMLElement): any {
if (!isSelectize(el)) {
return $(el).val();
} else {
const selectize = this._selectize(el);

return selectize?.getValue();
}
}
setValue(el: SelectHTMLElement, value: string): void {
if (!isSelectize(el)) {
Expand Down

0 comments on commit 134d2a0

Please sign in to comment.