@@ -3,6 +3,14 @@ buildbotSetupPlugin((reg) => {
let selectInputName = null;
let selectListName = null;
let inputRefs = null;
+ let selectors = new Map();
+ let lastName = null;
+
+ function selectedName() {
+ const input = document.getElementById(selectInputName);
+ const label = input && input.parentElement.previousElementSibling;
+ return label ? label.textContent.split(':')[0] : null;
+ }
const onTransitionEndEvent = (event) => {
/*
@@ -54,6 +62,7 @@ buildbotSetupPlugin((reg) => {
selectInputName = releaseSelector.attributes.getNamedItem('id').value;
const selectName = selectInputName.substring(0, selectInputName.lastIndexOf('-'));
selectListName = selectName + '-listbox';
+ lastName = selectedName();
}
window.addEventListener('transitionend', onTransitionEndEvent);
@@ -61,13 +70,13 @@ buildbotSetupPlugin((reg) => {
if (selectListName) {
const listDiv = document.getElementById(selectListName);
if (listDiv) {
- /*
- * The ReleaseSelector menu is shown: clean menu items.
- */
-
listDiv.childNodes.forEach(div => {
const sepIdx = div.textContent.indexOf(':');
if (sepIdx >= 0) {
+ try {
+ selectors.set(div.textContent.substring(0, sepIdx),
+ JSON.parse(div.textContent.substring(sepIdx + 1)));
+ } catch (e) {}
div.textContent = div.textContent.substring(0, sepIdx);
}
});
@@ -75,21 +84,11 @@ buildbotSetupPlugin((reg) => {
}
}
- function findApplySelector() {
- /*
- * One entry was clicked in the ReleaseSelector
- * menu: update all fields described by the
- * selector configuration.
- */
- const branchInput = document.getElementById(selectInputName);
- const inputText = branchInput.parentElement.previousElementSibling.textContent;
- const sepIdx = inputText.indexOf(':');
- const selectorName = inputText.substring(0, sepIdx);
- const selector = inputText.substring(sepIdx + 1);
-
- new Promise((resolve, reject) => {
- return applySelector(JSON.parse(selector), selectorName).then(resolve);
- });
+ function applySelectorByName(name) {
+ const selector = selectors.get(name);
+ if (selector) {
+ applySelector(selector, name).catch(e => console.error(e));
+ }
}
const onClick = (event) => {
@@ -98,18 +97,29 @@ buildbotSetupPlugin((reg) => {
if (event.target.parentElement) {
const parentId = event.target.parentElement.attributes.getNamedItem('id');
if (parentId && parentId.value == selectListName) {
- findApplySelector();
+ lastName = event.target.textContent.split(':')[0];
+ applySelectorByName(lastName);
}
}
}
window.addEventListener('click', onClick);
const onKeyDown = (event) => {
- if (event.key == "Enter") {
- findApplySelector();
- } else {
- updateSelectors();
- }
+ const branchInput = document.getElementById(selectInputName);
+ if (!branchInput || !branchInput.contains(event.target) || event.key != "Enter")
+ return;
+ /*
+ * The combobox commits the selection when Enter is pressed. Read the
+ * displayed label once the new value has been rendered (deferred), and
+ * apply the shortcut only if it actually changed.
+ */
+ setTimeout(() => {
+ const name = selectedName();
+ if (name && name != lastName) {
+ lastName = name;
+ applySelectorByName(name);
+ }
+ }, 0);
}
window.addEventListener('keydown', onKeyDown);
When a release shortcut was picked with the keyboard, the fields it maps to were not applied. Additionally, pressing return could raise a JS exception. Now the configuration is captured in a selectors map when the menu opens, and reused later. Also, return key only applies the selected entry when the focus is in the release selector field. [YOCTO #16291] AI-Generated: Uses opencode (DeepSeek V4 Flash) Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> --- yocto_console_view/src/releaseselectorfield.ts | 60 +++++++++++++++----------- 1 file changed, 35 insertions(+), 25 deletions(-)