Skip to content

Commit

Permalink
get folder from url
Browse files Browse the repository at this point in the history
  • Loading branch information
Axelcureno committed Dec 9, 2024
1 parent ee6bd94 commit 8785768
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions studio/src/mas-folder-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,33 @@ export class MasFolderPicker extends LitElement {
}));

if (this.options.length > 0) {
this.value = this.options[0].value;
this.label = this.options[0].label;
}
const urlParams = new URLSearchParams(window.location.search);
const pathParam = urlParams.get('path');
let matchedOption = null;

if (pathParam) {
matchedOption = this.options.find(
(option) => option.value === pathParam.toLowerCase(),
);
}
if (matchedOption) {
this.value = matchedOption.value;
this.label = matchedOption.label;
} else {
this.value = this.options[0].value;
this.label = this.options[0].label;
}

this.dispatchEvent(
new CustomEvent('folder-change', {
detail: { value: this.value, label: this.label },
bubbles: true,
composed: true,
}),
);

this.requestUpdate();
this.requestUpdate();
}
}

firstUpdated() {
Expand Down

0 comments on commit 8785768

Please sign in to comment.