-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add loading indicator to composition picker modal #21086
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
base: main
Are you sure you want to change the base?
Changes from all commits
ff7842a
6d31276
d8bceac
99127ab
d62c4fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,6 +42,14 @@ export class UmbCompositionPickerModalElement extends UmbModalBaseElement< | |||||||
| @state() | ||||||||
| private _usedForComposition: Array<string> = []; | ||||||||
|
|
||||||||
| /** | ||||||||
| * Loading state for the composition data fetch. | ||||||||
| * Initialized to true to show loader immediately when modal opens. | ||||||||
| * Set to false when data is successfully loaded or an error occurs. | ||||||||
| */ | ||||||||
| @state() | ||||||||
| private _loading = true; | ||||||||
|
|
||||||||
| override connectedCallback() { | ||||||||
| super.connectedCallback(); | ||||||||
|
|
||||||||
|
|
@@ -113,14 +121,19 @@ export class UmbCompositionPickerModalElement extends UmbModalBaseElement< | |||||||
| currentPropertyAliases: currentPropertyAliases, | ||||||||
| }); | ||||||||
|
|
||||||||
| if (!data) return; | ||||||||
| if (!data) { | ||||||||
| this._loading = false; | ||||||||
| return; | ||||||||
| } | ||||||||
|
|
||||||||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||||||||
| // @ts-expect-error | ||||||||
| const grouped = Object.groupBy(data, (item) => '/' + item.folderPath.join('/')); | ||||||||
| this._compatibleCompositions = Object.keys(grouped) | ||||||||
| .sort((a, b) => a.localeCompare(b)) | ||||||||
| .map((key) => ({ path: key, compositions: grouped[key] })); | ||||||||
|
|
||||||||
| this._loading = false; | ||||||||
| } | ||||||||
|
|
||||||||
| #onSelectionAdd(unique: string) { | ||||||||
|
|
@@ -183,6 +196,12 @@ export class UmbCompositionPickerModalElement extends UmbModalBaseElement< | |||||||
| } | ||||||||
|
|
||||||||
| #renderAvailableCompositions() { | ||||||||
| if (this._loading) { | ||||||||
| return html`<div id="loader" role="status" aria-live="polite" aria-label="Loading compositions"> | ||||||||
| <uui-loader></uui-loader> | ||||||||
| </div>`; | ||||||||
| } | ||||||||
|
|
||||||||
| if (this._compatibleCompositions) { | ||||||||
| return html` | ||||||||
| <umb-localize key="contentTypeEditor_compositionsDescription"> | ||||||||
|
|
@@ -242,6 +261,14 @@ export class UmbCompositionPickerModalElement extends UmbModalBaseElement< | |||||||
|
|
||||||||
| static override styles = [ | ||||||||
| css` | ||||||||
| #loader { | ||||||||
| display: flex; | ||||||||
| justify-content: center; | ||||||||
| align-items: center; | ||||||||
| padding: var(--uui-size-layout-1); | ||||||||
| min-height: 200px; | ||||||||
|
Comment on lines
+267
to
+269
|
||||||||
| align-items: center; | |
| padding: var(--uui-size-layout-1); | |
| min-height: 200px; |
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.
[nitpick] The loader div includes accessibility attributes
role="status",aria-live="polite", andaria-label="Loading compositions". While these attributes improve accessibility, they differ from the reference implementation inblock-catalogue-modal.element.ts(line 208), which doesn't include any accessibility attributes.For consistency and better accessibility across the application, consider:
The current attributes are appropriate and follow WCAG guidelines for live regions.