Skip to content

Commit

Permalink
[#2656] Fix bug with SelectChoices#find only returning results from f…
Browse files Browse the repository at this point in the history
…irst category
  • Loading branch information
arbron committed Dec 1, 2023
1 parent 6880955 commit 322650e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions module/documents/actor/select-choices.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export default class SelectChoices {
/**
* Find key and value for the provided key or key suffix.
* @param {string} key Full prefixed key (e.g. `tool:art:alchemist`) or just the suffix (e.g. `alchemist`).
* @returns {[string, SelectChoicesEntry]} An array with the first value being the matched key, and the second
* being the value.
* @returns {[string, SelectChoicesEntry]|null} An array with the first value being the matched key,
* and the second being the value.
*/
find(key) {
for ( const [k, v] of Object.entries(this) ) {
Expand All @@ -78,7 +78,7 @@ export default class SelectChoices {
if ( result ) return result;
}
}
return [];
return null;
}

/* -------------------------------------------- */
Expand Down
4 changes: 2 additions & 2 deletions module/documents/actor/trait.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export async function actorValues(actor, trait) {
const traitChoices = await choices(trait, {prefixed: true});

const setValue = (k, v) => {
const [key] = traitChoices.find(k);
if ( key ) values[key] = v;
const result = traitChoices.find(k);
if ( result ) values[result[0]] = v;
};

if ( ["skills", "tool"].includes(trait) ) {
Expand Down

0 comments on commit 322650e

Please sign in to comment.