-
Notifications
You must be signed in to change notification settings - Fork 6
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
nmerget
wants to merge
35
commits into
main
Choose a base branch
from
fix-a11y-form-component-ids
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
5fcc7b0
fix: a11y issue for all form components
nmerget 3514dd4
Merge branch 'main' of github.com:db-ui/mono into fix-a11y-form-compo…
nmerget 51c14bf
fix: a11y issue for switch
nmerget dabcf94
fix: issue from PR
nmerget 2b04630
Merge branch 'main' into fix-a11y-form-component-ids
nmerget 28d00c9
fix: issue with vue
nmerget fa45de4
Merge remote-tracking branch 'origin/fix-a11y-form-component-ids' int…
nmerget 55ddd0d
Merge branch 'main' into fix-a11y-form-component-ids
mfranzke 91b2e60
Update packages/components/src/components/select/select.lite.tsx
nmerget ded12f9
Update checkbox.lite.tsx
mfranzke 286eae3
Update input.lite.tsx
mfranzke 524e892
Update textarea.lite.tsx
mfranzke 4ad533c
Update input.lite.tsx
mfranzke 613e971
fix: issues from PR
nmerget 2f92ef4
Merge remote-tracking branch 'origin/fix-a11y-form-component-ids' int…
nmerget ad99509
Merge branch 'main' into fix-a11y-form-component-ids
nmerget 99da69a
Merge branch 'main' into fix-a11y-form-component-ids
nmerget 315e2e0
fix: issues with form-components
nmerget ea3abae
fix: removed unused dependency
nmerget 3fd2d65
feat: add new tests for form-components for react- and vue-showcase
nmerget 809fd76
Merge branch 'main' of github.com:db-ui/mono into fix-a11y-form-compo…
nmerget ce2d6a1
feat: add new tests for form-components for angular-showcase
nmerget 54529cc
Merge branch 'main' into fix-a11y-form-component-ids
nmerget 8749d59
Merge branch 'main' into fix-a11y-form-component-ids
nmerget 70f4b76
fix: issue from PR
nmerget bb1987e
chore: update from main
nmerget 309091f
Merge branch 'main' of github.com:db-ui/mono into fix-a11y-form-compo…
nmerget 072bb2b
fix: issue with angular
nmerget a641c27
Merge branch 'main' into fix-a11y-form-component-ids
nmerget 484ed3a
Merge branch 'main' into fix-a11y-form-component-ids
mfranzke dff6ca5
Merge branch 'main' of github.com:db-ui/mono into fix-a11y-form-compo…
nmerget 09f1f23
chore: update from main
nmerget c823486
fix: issue with vue showcase
nmerget 91f7074
Merge branch 'main' of github.com:db-ui/mono into fix-a11y-form-compo…
nmerget 6abdad7
fix: issue with vue refs
nmerget File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ import { | |
import { cls, uuid } from '../../utils'; | ||
import { DBInputProps, DBInputState } from './model'; | ||
import { | ||
DEFAULT_ID, | ||
DEFAULT_INVALID_MESSAGE, | ||
DEFAULT_INVALID_MESSAGE_ID_SUFFIX, | ||
DEFAULT_LABEL, | ||
|
@@ -35,12 +34,17 @@ export default function DBInput(props: DBInputProps) { | |
const ref = useRef<HTMLInputElement>(null); | ||
// jscpd:ignore-start | ||
const state = useStore<DBInputState>({ | ||
_id: DEFAULT_ID, | ||
_messageId: DEFAULT_ID + DEFAULT_MESSAGE_ID_SUFFIX, | ||
_validMessageId: DEFAULT_ID + DEFAULT_VALID_MESSAGE_ID_SUFFIX, | ||
_invalidMessageId: DEFAULT_ID + DEFAULT_INVALID_MESSAGE_ID_SUFFIX, | ||
_descByIds: '', | ||
_dataListId: DEFAULT_ID, | ||
_id: 'input-' + uuid(), | ||
_messageId: this._id + DEFAULT_MESSAGE_ID_SUFFIX, | ||
_validMessageId: this._id + DEFAULT_VALID_MESSAGE_ID_SUFFIX, | ||
_invalidMessageId: this._id + DEFAULT_INVALID_MESSAGE_ID_SUFFIX, | ||
_descByIds: | ||
this._messageId + | ||
' ' + | ||
this._validMessageId + | ||
' ' + | ||
this._invalidMessageId, | ||
_dataListId: `datalist-` + uuid(), | ||
nmerget marked this conversation as resolved.
Show resolved
Hide resolved
|
||
defaultValues: { | ||
label: DEFAULT_LABEL, | ||
placeholder: ' ' | ||
|
@@ -96,31 +100,27 @@ export default function DBInput(props: DBInputProps) { | |
}); | ||
|
||
onMount(() => { | ||
state._id = props.id || 'input-' + uuid(); | ||
state._dataListId = props.dataListId || `datalist-${uuid()}`; | ||
state._id = props.id ?? state._id; | ||
state._dataListId = props.dataListId ?? state._dataListId; | ||
}); | ||
|
||
onUpdate(() => { | ||
if (state._id) { | ||
state._messageId = state._id + DEFAULT_MESSAGE_ID_SUFFIX; | ||
state._validMessageId = state._id + DEFAULT_VALID_MESSAGE_ID_SUFFIX; | ||
state._invalidMessageId = | ||
const messageId = state._id + DEFAULT_MESSAGE_ID_SUFFIX; | ||
const validMessageId = state._id + DEFAULT_VALID_MESSAGE_ID_SUFFIX; | ||
const invalidMessageId = | ||
Comment on lines
+114
to
+115
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
state._id + DEFAULT_INVALID_MESSAGE_ID_SUFFIX; | ||
} | ||
}, [state._id]); | ||
state._messageId = messageId; | ||
state._validMessageId = validMessageId; | ||
state._invalidMessageId = invalidMessageId; | ||
|
||
onUpdate(() => { | ||
const descByIds = [state._validMessageId, state._invalidMessageId]; | ||
if (props.message) { | ||
descByIds.push(state._messageId); | ||
state._descByIds = [ | ||
messageId, | ||
validMessageId, | ||
invalidMessageId | ||
].join(' '); | ||
} | ||
state._descByIds = descByIds.join(' '); | ||
}, [ | ||
props.message, | ||
state._messageId, | ||
state._validMessageId, | ||
state._invalidMessageId | ||
]); | ||
}, [state._id]); | ||
|
||
return ( | ||
<div | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nmerget marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nmerget marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nmerget marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?