-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add indexing of dropdown entries #2004
Changes from 3 commits
24a966d
0aecc1b
83db087
79ae8d6
059292c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,9 +161,45 @@ | |
this.flyoutItems_ = query ? | ||
this.blockSearcher.blockTypesMatching(query).map( | ||
(blockType) => { | ||
// check the block if it has dropdowns | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remove the inline comments throughout? I think the code is self-explanatory! |
||
// get the block | ||
const block = this.workspace_.newBlock(blockType); | ||
// get the inputs | ||
const inputs = block.inputList; | ||
// iterate through the inputs | ||
for (let input of inputs) { | ||
// get the fields | ||
const fields = input.fieldRow; | ||
// iterate through the fields | ||
for (let field of fields) { | ||
// check if the field is a dropdown | ||
if (field instanceof Blockly.FieldDropdown) { | ||
// get the options | ||
const options = field.getOptions(); | ||
// iterate through the options | ||
for (let option of options) { | ||
// check if the query is in the option | ||
// make sure the option is text | ||
if (typeof option[0] === 'string' && | ||
option[0].toLowerCase().includes(query.toLowerCase())) { | ||
Check failure on line 184 in plugins/toolbox-search/src/toolbox_search.ts
|
||
|
||
let fields = {} | ||
Check failure on line 186 in plugins/toolbox-search/src/toolbox_search.ts
|
||
fields[field.name] = option[1] | ||
return { | ||
kind: 'block', | ||
type: blockType, | ||
fields: fields | ||
}; | ||
} | ||
}; | ||
} | ||
} | ||
} | ||
|
||
return { | ||
kind: 'block', | ||
type: blockType, | ||
|
||
}; | ||
}) : []; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to this file are unnecessary because the other PR added indexing.