Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spike: a11y errors on the preview #76

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions example/resources/form.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
{
"components": [
{
"type": "text",
"text": "# Invoice\nLorem _ipsum_ __dolor__ `sit`.\n \n \nA list of BPMN symbols:\n* Start Event\n* Task\nLearn more about [forms](https://bpmn.io).\n \n \nThis [malicious link](javascript:throw onerror=alert,'some string',123,'haha') __should not work__."
},
{
"key": "creditor",
"label": "Creditor",
"type": "textfield",
"validate": {
"required": true
}
},
{
"description": "An invoice number in the format: C-123.",
"key": "invoiceNumber",
"label": "Invoice Number",
"type": "textfield",
"validate": {
"pattern": "^C-[0-9]+$"
}
},
{
"type": "image",
"source": "https://foo.png"
},
{
"key": "amount",
"label": "Amount",
Expand Down
24 changes: 24 additions & 0 deletions example/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const container = document.querySelector('.playground');

const designBtn = document.querySelector('.design');
const validateBtn = document.querySelector('.validate');
const checkA11yBtn = document.querySelector('.check-a11y');

const data = {
creditor: 'John Doe Company',
Expand Down Expand Up @@ -39,6 +40,7 @@ const data = {
};

let mode;
let a11yEnabled = false;

const formPlayground = new CamundaFormPlayground({
container,
Expand Down Expand Up @@ -79,8 +81,30 @@ function triggerDesign() {
formPlayground.collapse();
}

function toggleA11y() {
a11yEnabled = !a11yEnabled;

const form = formPlayground.getForm();
const formEditor = formPlayground.getEditor();

const onSchemaChanged = async () => {
setTimeout(() => form.get('a11yValidation').execute(), 500);
};

if (a11yEnabled) {
form.get('a11yValidation').execute();
checkA11yBtn.classList.add('active');
formEditor.on('changed', onSchemaChanged);
} else {
checkA11yBtn.classList.remove('active');
formEditor.off('changed', onSchemaChanged);
form.get('a11yValidation').clear();
}
}

designBtn.addEventListener('click', triggerDesign);
validateBtn.addEventListener('click', triggerValidation);
checkA11yBtn.addEventListener('click', toggleA11y);

document.body.addEventListener('keydown', function(event) {
if (event.code === 'KeyP' && event.shiftKey && (event.metaKey || event.ctrlKey)) {
Expand Down
1 change: 1 addition & 0 deletions example/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
</button>
</div>
<div class="buttons">
<button class="check-a11y">Check a11y</button>
<span class="execution-platform">5.2.0</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion tasks/link-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const customLinkersMap = {
'bpmn-io/form-js': linkFormJs
};

const DEFAULT_BRANCH = 'develop';
const DEFAULT_BRANCH = 'a11y-errors-viewer';

const demoDir = path.join(__dirname, '..');
const dependenciesDir = path.join(__dirname, '.linked-dependencies');
Expand Down