diff --git a/package-lock.json b/package-lock.json index 595de35..4d89912 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "aws-extend-switch-roles", - "version": "5.0.0", + "version": "5.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "aws-extend-switch-roles", - "version": "5.0.0", + "version": "5.0.1", "license": "MIT", "dependencies": { - "aesr-config": "^0.4.1" + "aesr-config": "^0.5.1" }, "devDependencies": { "@playwright/test": "^1.38.1", @@ -266,9 +266,9 @@ "dev": true }, "node_modules/aesr-config": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/aesr-config/-/aesr-config-0.4.1.tgz", - "integrity": "sha512-dVQOswZtzdHt+fxh2PfkzgupV/EvSXmL+gsSR33sQoCak51Ayd3yt94sQRsc411LkpUWC2Ffs7heC/NQau1aMA==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/aesr-config/-/aesr-config-0.5.1.tgz", + "integrity": "sha512-8OVC0aY+8X6waJISzxVqMrbZTJlLMG1b2cNZQGnVT6XliWRSWy6OUioRVM/xETjs/ma2pPrrFztwWISjX2vUgQ==", "bin": { "parse-aesr-config": "bin/parse-aesr-config.js" }, @@ -2023,9 +2023,9 @@ "dev": true }, "aesr-config": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/aesr-config/-/aesr-config-0.4.1.tgz", - "integrity": "sha512-dVQOswZtzdHt+fxh2PfkzgupV/EvSXmL+gsSR33sQoCak51Ayd3yt94sQRsc411LkpUWC2Ffs7heC/NQau1aMA==" + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/aesr-config/-/aesr-config-0.5.1.tgz", + "integrity": "sha512-8OVC0aY+8X6waJISzxVqMrbZTJlLMG1b2cNZQGnVT6XliWRSWy6OUioRVM/xETjs/ma2pPrrFztwWISjX2vUgQ==" }, "agent-base": { "version": "6.0.2", diff --git a/package.json b/package.json index b945dd1..93e0a7a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "homepage": "https://github.com/tilfinltd/aws-extend-switch-roles#readme", "dependencies": { - "aesr-config": "^0.4.1" + "aesr-config": "^0.5.1" }, "devDependencies": { "@playwright/test": "^1.38.1", diff --git a/src/js/options.js b/src/js/options.js index 9088831..6b5f68d 100644 --- a/src/js/options.js +++ b/src/js/options.js @@ -84,6 +84,7 @@ window.onload = function() { msg = "Configuration cannot be saved while using Private Browsing." } updateMessage('msgSpan', msg, 'warn'); + if (typeof lastError.line === 'number') focusConfigTextArea(lastError.line); }); } catch (e) { updateMessage('msgSpan', `Failed to save because ${e.message}`, 'warn'); @@ -260,3 +261,19 @@ function updateRemoteFieldsState(state) { elById('configHubPanel').style.display = 'none'; } } + +function focusConfigTextArea(ln) { + const ta = document.getElementById('awsConfigTextArea'); + ta.scrollTop = ln < 10 ? 0 : 16 * (ln - 10); + const lines = ta.value.split('\n'); + if (ln === 1) { + ta.setSelectionRange(0, lines[0].length + 1); + ta.focus(); + return; + } + ln--; + const start = lines.slice(0, ln).join('\n').length + 1; + const end = start + lines[ln].length; + ta.setSelectionRange(start, end); + ta.focus(); +} diff --git a/test/emulator/options.spec.js b/test/emulator/options.spec.js index 00223b1..aaa72f2 100644 --- a/test/emulator/options.spec.js +++ b/test/emulator/options.spec.js @@ -27,7 +27,7 @@ source_profile = src/B [profile A/2] aws_account_id = 000011112224 role_name=target-a2 -color=#00cc33 +color=00cc33 source_profile=src-A ; comment`); await page.locator('#saveButton').click();