-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Check for duplicates
- I have searched for similar issues before opening a new one.
Description
Using an HTML element in a dropdown field results in the warning, "Can't get text for existing dropdown option. If you're using HTMLElement dropdown options in node, ensure you're using jsdom-global or similar."
and the use of the field's value rather than its title
, ariaLabel
, or innerText
as is intended. The HTML element is not displayed.
The problem occurs in trimOptions
, where this ternary statement replaces the HTML element (label
) with {...label}
. The resulting object does not have type HTMLElement
, so the option fails the test option instanceof HTMLElement
in getText_
.
The solution is probably to change the false
outcome of the ternary statement from {...label}
to label
. The spread was previously necessary when we weren't strict about requiring image options to have all four properties. The addition of isImageProperties
now requires this (see validateOptions
, so the only thing that drops through are HTMLElements
.
Reproduction steps
See https://jsfiddle.net/rpbourret/18z6p2vf/32/ or run the following code:
Blockly.Blocks["headings_dropdown"] = {
init: function() {
var input = this.appendDummyInput()
.appendField("heading");
var options = [
[h1, "H1VALUE"],
];
input.appendField(new Blockly.FieldDropdown(options), "HEADING");
}
};
const toolbox = {
kind: "flyoutToolbox",
contents: [
{
kind: "block",
type: "headings_dropdown",
},
],
}
const workspace = Blockly.inject("blocklyDiv", {
toolbox: toolbox,
})
Stack trace
Screenshots
No response
Browsers
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status