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

Fix a11y form component ids #2599

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open

Fix a11y form component ids #2599

wants to merge 35 commits into from

Conversation

nmerget
Copy link
Member

@nmerget nmerget commented Apr 30, 2024

Proposed changes

closes #2588

  • changed form-components to work with aria-describedby and messages
  • add new showcase tests to check if every framework works with every specific form implementation to make sure nothing breaks

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (fix on existing components or architectural decisions)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Further comments

Copy link
Contributor

🔭🐙🐈 Test this branch here: https://db-ui.github.io/mono/review/fix-a11y-form-component-ids

@github-actions github-actions bot added the 🏘components Changes inside components folder label Apr 30, 2024
@nmerget nmerget enabled auto-merge (squash) April 30, 2024 14:47
@nmerget nmerget marked this pull request as draft April 30, 2024 15:25
auto-merge was automatically disabled April 30, 2024 15:25

Pull request was converted to draft

@nmerget nmerget marked this pull request as ready for review May 3, 2024 05:54
@nmerget nmerget enabled auto-merge (squash) May 6, 2024 06:06
@nmerget nmerget requested a review from mfranzke May 8, 2024 14:56
@github-actions github-actions bot added the 📺showcases Changes to 1-n showcases label May 10, 2024
@nmerget nmerget marked this pull request as draft May 10, 2024 13:18
auto-merge was automatically disabled May 10, 2024 13:18

Pull request was converted to draft

@nmerget nmerget marked this pull request as ready for review May 13, 2024 09:44
@nmerget nmerget enabled auto-merge (squash) May 13, 2024 09:45
@nmerget nmerget requested a review from mfranzke May 15, 2024 09:28
@nmerget nmerget linked an issue May 24, 2024 that may be closed by this pull request
2 tasks
@mfranzke mfranzke removed their assignment May 29, 2024
mfranzke and others added 2 commits May 30, 2024 15:31
@nmerget nmerget requested a review from bruno-sch as a code owner June 26, 2024 13:32
Comment on lines +102 to +104
{
from: 'props.value ?? _value',
to: 'props.value'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you perhaps also add an explanation here?

Comment on lines +67 to +69
{
from: /this.\$refs.ref\?.validationMessage/g,
to: 'this?.$refs.ref?.validationMessage'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you perhaps also add an explanation here?

Comment on lines +73 to +86
// This is a workaround for valid/invalidMessages resetting values
[
'HTMLSelectElement',
'HTMLInputElement',
'HTMLTextAreaElement'
].forEach((element) => {
replacements.push({
from: `handleInput(event: InputEvent<${element}>) {`,
to:
`handleInput(event: InputEvent<${element}>) {\n` +
'this._value = (event.target as any).value;'
});
});

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without further explanation, I don't think it's clear what's happening here.

Comment on lines +87 to +88
const validMessageId = state._id + DEFAULT_VALID_MESSAGE_ID_SUFFIX;
const invalidMessageId =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two values could be assigned directly to the states. Do you do this for reasons of consistency?

Comment on lines +114 to +115
const validMessageId = state._id + DEFAULT_VALID_MESSAGE_ID_SUFFIX;
const invalidMessageId =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two values could be assigned directly to the states. Do you do this for reasons of consistency?

Comment on lines +69 to +84
if (!ref?.validity.valid || props.customValidity === 'invalid') {
state._descByIds = state._invalidMessageId;
} else if (
props.customValidity === 'valid' ||
(ref?.validity.valid &&
(props.required ||
props.minLength ||
props.maxLength ||
props.pattern))
) {
state._descByIds = state._validMessageId;
} else if (props.message) {
state._descByIds = state._messageId;
} else {
state._descByIds = 'none';
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be useful to briefly describe the benefits of this block...

Comment on lines +126 to +134
...Array.from<Element>(
ref.querySelectorAll('& > .db-tab-panel')
),
...Array.from<Element>(
ref.querySelectorAll('& > dbtabpanel > .db-tab-panel')
),
...Array.from<Element>(
ref.querySelectorAll('& > db-tab-panel > .db-tab-panel')
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you select the tab panels for the various frameworks here (automatic wrapping of the components)? If so, two querySelectorAll would be unnecessary at runtime - right?

);
}
tabPanels.forEach((panel: Element, index: number) => {
if (!panel.id) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (panel.id) return;
...

A guard clause would avoid indentation and possibly increase readability.

</DBTabList>
</db-tab-item>
<db-tab-item icon="airplane" [noText]="true"></db-tab-item>
</db-tab-list>
<DBTabPanel>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also write in kebap-case?

Comment on lines 321 to 322
</DBTabPanel>
<DBTabPanel>Tab Panel 5</DBTabPanel>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also write in kebap-case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏘components Changes inside components folder 📺showcases Changes to 1-n showcases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Form Components: Accessibility Tree not updating when id changes Showcase: unify forms
3 participants