From 08e1dde3dd2e0cb89d3be5c1312d29f3be3f8c74 Mon Sep 17 00:00:00 2001 From: Nikolay Deshev Date: Fri, 5 Dec 2025 12:59:29 +0200 Subject: [PATCH 1/2] fix(ui5-ai-textarea): add docs and correct samples adjust samples and test pages to reflect the changes made in #12638 --- packages/ai/test/pages/TextArea.html | 29 +++++++++++--- .../_samples/ai/TextArea/Extended/main.js | 39 ++++++++++++------- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/packages/ai/test/pages/TextArea.html b/packages/ai/test/pages/TextArea.html index 0a93922e8a7c..5ab08eeb80ec 100644 --- a/packages/ai/test/pages/TextArea.html +++ b/packages/ai/test/pages/TextArea.html @@ -193,7 +193,7 @@

AI TextArea Component

textarea.value = versionHistory[versionIndex].value; } - textarea.currentVersion = currentIndexHistory; + textarea.currentVersion = currentIndexHistory + 1; textarea.totalVersions = versionHistory.length; if (versionHistory[currentIndexHistory]) { @@ -366,13 +366,30 @@

AI TextArea Component

stopTypingAnimation(); currentGenerationIndex += 1; - // Restore the previous content instead of saving the cancelled action - textarea.value = contentBeforeGeneration; + // Save the stopped generation if there is content + const stoppedValue = textarea.value; + if (stoppedValue.trim()) { + const menuItem = findMenuItemByAction(currentActionInProgress); + const completedLabel = (menuItem && menuItem.dataset.completedLabel) + ? menuItem.dataset.completedLabel + " (stopped)" + : "Generation stopped"; + + versionHistory.push({ + value: stoppedValue, + action: currentActionInProgress, + endAction: completedLabel, + timestamp: new Date().toISOString() + }); + + // Restore the previous content + textarea.value = contentBeforeGeneration; + currentIndexHistory = versionHistory.length - 1; + buildMenuFromConfig(); + updateComponentState(); + } + currentActionInProgress = null; textarea.loading = false; - textarea.promptDescription = ""; - - updateComponentState(); } function handleVersionChange(event) { diff --git a/packages/website/docs/_samples/ai/TextArea/Extended/main.js b/packages/website/docs/_samples/ai/TextArea/Extended/main.js index 755e2eadb5fe..262d57e30f45 100644 --- a/packages/website/docs/_samples/ai/TextArea/Extended/main.js +++ b/packages/website/docs/_samples/ai/TextArea/Extended/main.js @@ -72,6 +72,7 @@ let currentIndexHistory = 0; let currentActionInProgress = null; let typingInterval = null; let currentGenerationIndex = 0; +let contentBeforeGeneration = ""; const textarea = document.getElementById('ai-textarea'); const menu = document.getElementById('ai-menu'); @@ -95,7 +96,7 @@ function updateComponentState(versionIndex = null) { textarea.value = versionHistory[versionIndex].value; } - textarea.currentVersion = currentIndexHistory; + textarea.currentVersion = currentIndexHistory + 1; textarea.totalVersions = versionHistory.length; if (versionHistory[currentIndexHistory]) { @@ -242,6 +243,7 @@ async function executeAction(action) { const textKey = menuItem.dataset.textKey || 'en'; saveCurrentVersion(); + contentBeforeGeneration = textarea.value; currentActionInProgress = action; currentGenerationIndex += 1; const generationIdForThisRun = currentGenerationIndex; @@ -267,22 +269,29 @@ function stopGeneration() { stopTypingAnimation(); currentGenerationIndex += 1; - const action = currentActionInProgress || 'generate'; - const menuItem = findMenuItemByAction(action); - const completedLabel = (menuItem && menuItem.dataset.completedLabel) ? menuItem.dataset.completedLabel : 'Action completed'; - - versionHistory.push({ - value: textarea.value, - action, - endAction: completedLabel + " (stopped)", - timestamp: new Date().toISOString() - }); + + // Save the stopped generation if there is content + const stoppedValue = textarea.value; + if (stoppedValue.trim()) { + const action = currentActionInProgress || 'generate'; + const menuItem = findMenuItemByAction(action); + const completedLabel = (menuItem && menuItem.dataset.completedLabel) ? menuItem.dataset.completedLabel : 'Action completed'; + + versionHistory.push({ + value: stoppedValue, + action, + endAction: completedLabel + " (stopped)", + timestamp: new Date().toISOString() + }); + + // Restore the previous content + textarea.value = contentBeforeGeneration; + currentIndexHistory = versionHistory.length - 1; + buildMenuFromConfig(); + updateComponentState(); + } - currentIndexHistory = versionHistory.length - 1; currentActionInProgress = null; - - buildMenuFromConfig(); - updateComponentState(); textarea.loading = false; } From 203d9e65a0d517efae07d7522c8dcbd96c2b31b6 Mon Sep 17 00:00:00 2001 From: Nikolay Deshev Date: Wed, 17 Dec 2025 09:50:43 +0200 Subject: [PATCH 2/2] docs(ui5-ai-textarea): add docs and correct samples do not restore previous value on generation cancelation --- packages/ai/test/pages/TextArea.html | 3 --- packages/website/docs/_samples/ai/TextArea/Extended/main.js | 3 --- 2 files changed, 6 deletions(-) diff --git a/packages/ai/test/pages/TextArea.html b/packages/ai/test/pages/TextArea.html index 5ab08eeb80ec..b573e67fe99e 100644 --- a/packages/ai/test/pages/TextArea.html +++ b/packages/ai/test/pages/TextArea.html @@ -366,7 +366,6 @@

AI TextArea Component

stopTypingAnimation(); currentGenerationIndex += 1; - // Save the stopped generation if there is content const stoppedValue = textarea.value; if (stoppedValue.trim()) { const menuItem = findMenuItemByAction(currentActionInProgress); @@ -381,8 +380,6 @@

AI TextArea Component

timestamp: new Date().toISOString() }); - // Restore the previous content - textarea.value = contentBeforeGeneration; currentIndexHistory = versionHistory.length - 1; buildMenuFromConfig(); updateComponentState(); diff --git a/packages/website/docs/_samples/ai/TextArea/Extended/main.js b/packages/website/docs/_samples/ai/TextArea/Extended/main.js index 262d57e30f45..f85217ce2480 100644 --- a/packages/website/docs/_samples/ai/TextArea/Extended/main.js +++ b/packages/website/docs/_samples/ai/TextArea/Extended/main.js @@ -270,7 +270,6 @@ function stopGeneration() { stopTypingAnimation(); currentGenerationIndex += 1; - // Save the stopped generation if there is content const stoppedValue = textarea.value; if (stoppedValue.trim()) { const action = currentActionInProgress || 'generate'; @@ -284,8 +283,6 @@ function stopGeneration() { timestamp: new Date().toISOString() }); - // Restore the previous content - textarea.value = contentBeforeGeneration; currentIndexHistory = versionHistory.length - 1; buildMenuFromConfig(); updateComponentState();