Skip to content

[dev-v5] fix: FluentText.As semantic rendering non functional in FluentText #4993

Description

@codeaphex

🐛 Bug Report

💻 Repro or Code Sample

Put this into a new page

<FluentText Block As="TextTag.H1">This content is rendered inside an h1 element.</FluentText>
<FluentText Block As="TextTag.H2">This content is rendered inside an h2 element.</FluentText>
<FluentText Block As="TextTag.H3">This content is rendered inside an h3 element.</FluentText>
<FluentText Block As="TextTag.H4">This content is rendered inside an h4 element.</FluentText>
<FluentText Block As="TextTag.H5">This content is rendered inside an h5 element.</FluentText>
<FluentText Block As="TextTag.H6">This content is rendered inside an h6 element.</FluentText>
<FluentText Block As="TextTag.Paragraph">This content
    is rendered inside a
    a p element.
</FluentText>
<FluentText Block As="TextTag.Pre">This content
is rendered inside a
a pre element.
</FluentText>
<FluentText Block As="TextTag.Span">This content is rendered inside a span element.</FluentText>

🤔 Expected Behavior

The content should be rendered inside a semantic HTML element using the slot of the underlying web component and should apply the css of that element this way.

<fluent-text block="">
  <template shadowrootmode="open">
     <slot></slot>
   </template>
   <!--!-->
  <h1>This content is rendered inside an h1 element.</h1>
</fluent-text>

😯 Current Behavior

The content is directly applied to the fluent-text webcomponent and the As property is applied to fluent-text via the as attribute. The web component doesnt handle as attributes though (I think the fluent react component might do it). So the component is rendered non semantically and without proper css.

<fluent-text as="h1"></fluent-text>

💁 Possible Solution

I can submit a PR to fix this via your AddTag component.
Lots of tests needed updates because they assume the output of the current behavior.

🔦 Context

Render semantic html with correct formatting applied.

🌍 Your Environment

  • OS & Device: Windows
  • Browser Microsoft Edge
  • .NET and Fluent UI Blazor library Version [v5 RC4]

Metadata

Metadata

Assignees

Labels

bugA bugclosed:doneWork is finished. The version in which the work will show up might not have been released yet!v5For the next major version

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions