Skip to content

chore(skeleton): added screen reader text - #7716

Merged
thatblindgeye merged 5 commits into
patternfly:mainfrom
Mash707:skeleton-add-screen-reader-text
Aug 14, 2025
Merged

thatblindgeye merged 5 commits into
patternfly:mainfrom
Mash707:skeleton-add-screen-reader-text

Conversation

@Mash707

@Mash707 Mash707 commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

Fixes: #7290

{{#* inline "page-template-section"}}
{{#> page-main-section}}
{{#> gallery gallery--modifier="pf-m-gutter"}}
<span class="pf-v6-screen-reader">Loading content</span>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@thatblindgeye I am not sure if this is the correct place for the span.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We'd want this text to be a direct child of a skeleton. What we could do is allow a way to pass some custom screen reader text inside the card-skeleton.hbs file, and then update this demo to pass that into the card-skeleton instances. We could even have it fallback to some default "Loading card content" text or similar. For this particular demo, whether each card should actually have their own screen reader text is iffy. In certain scenarions it may make sense to do that... for here, we could keep it simple and just apply a screen reader text to the first card.

@mcoker do we intend on ever using the table-skeleton at all? We have a file for it but it's not used anywhere. If we do we'd want to make a similar update there.

@mcoker mcoker Aug 1, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@thatblindgeye not that I know of. You're welcome to remove that file if you'd like. I see it's referencing {{#> skeleton-element}} which doesn't appear to exist. FYI, it would be defined either as a file named skeleton-element.hbs OR sometimes we have "inline" partials where we define the partial name and code in some other file, but I searched the repo for "skeleton-element" and didn't see an inline partial anywhere.

If skeletons should always have some text, should we just have some logic in skeleton.hbs that's like this, then we'd just specify skeleton--HasNoText=true for ones we want to omit (like all but the first card in that demo)

{{#unless skeleton--HasNoText}}
  {{#if skeleton--text}}
    {{skeleton--text}}
  {{else}}
    Loading content
  {{/if}}
{{/unless}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could do that. Would be handy when there's only one section of a skeleton being used in an example/demo, though we'd just need to make sure to provide more unique text when there's multiple sections that need some sort of content

@patternfly-build

patternfly-build commented Aug 1, 2025 •

Copy link
Copy Markdown
Collaborator

### Default
```hbs
{{#> skeleton}}
<span class="pf-v6-screen-reader">Loading default content</span>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a hbs partial that will generate this element for you - screen-reader.hbs

Suggested change
<span class="pf-v6-screen-reader">Loading default content</span>
{{#> screen-reader}}Loading default content{{/screen-reader}}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will the make the changes.

@Mash707
Mash707 requested a review from thatblindgeye August 14, 2025 17:37

@thatblindgeye thatblindgeye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would you mind also deleting the table-skeleton file? Based on Coker's comments above it doesn't sound necessary and is just another thing we have to worry about in the future.

{{#> card-body}}
{{#> l-flex l-flex--modifier="pf-m-column pf-m-spacer-md"}}
{{#> skeleton}}
{{#if isFirstCard}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The naming of this handlebars attribute is pretty close. In a sense they can be similar in naming structure to our React props, one difference being that we'll prefix the attribute with the component and a double hyphen, and the attribute will be pascal case, so something like

Suggested change
{{#if isFirstCard}}
{{#if card-skeleton--IsFirstCard}}

That said, implementing the feedback from Coker where the skeleton.hbs file has a default value could be a nice to have, though that could be where you can get into how complex handlebars can be/feel. I wouldn't consider implementing that a priority and would be slightly out of scope so if you want to pass on it that's fine.

If you want to make an attempt, ideally the logic should be:

  • skeleton.hbs has logic either where unless skeleton--HasNoText or if skeleton-IsFirstSkeleton (or something), then we either render whatever is passed to skeleton--text or a default string of Loading conternt". We could also just use @partial-blockinstead ofskeleton--text`, though I'd leave that up to Coker if he has a preference as I don't
  • From there, within card-skeletong.hbs, the logic you have now would have to be tweaked slightly if we went with the skeleton--text approach, possibly utilizing the handblebars ternary function we have and passing that into skeleton--text to check if card-skeleton--IsFirstCard is true, passing in the loading text here if so or an empty string if not. Coker may have a less complicated approach, though.

@Mash707
Mash707 requested a review from thatblindgeye August 14, 2025 19:15
@thatblindgeye
thatblindgeye requested a review from mcoker August 14, 2025 19:18

@mcoker mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔥🔥🔥

Thanks @Mash707!!

@thatblindgeye
thatblindgeye merged commit 9005060 into patternfly:main Aug 14, 2025
@Mash707
Mash707 deleted the skeleton-add-screen-reader-text branch August 17, 2025 19:45
@patternfly-build

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 6.3.0-prerelease.50 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skeleton - at least one skeleton per example should include screen reader text

4 participants