Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/honest-animals-stop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@spectrum-css/fieldlabel": patch
---

#### Fix fieldlabel required icon wrapping

Addresses case where fieldlabel required icon could appear on its own line when wrapping by applying text-wrap: pretty; to the parent label class and adding a non-breaking space character between the label content and required marker.
3 changes: 2 additions & 1 deletion components/fieldlabel/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2024 Adobe. All rights reserved.
* Copyright 2025 Adobe. All rights reserved.
*
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
Expand Down Expand Up @@ -85,6 +85,7 @@

.spectrum-FieldLabel {
display: block;
Comment thread
rise-erpelding marked this conversation as resolved.
text-wrap: pretty;
box-sizing: border-box;
min-block-size: var(--mod-fieldlabel-min-height, var(--spectrum-fieldlabel-min-height));

Expand Down
2 changes: 2 additions & 0 deletions components/fieldlabel/stories/fieldlabel.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ RightAligned.storyName = "Right-aligned";
* Field labels for required inputs can be marked with an asterisk at the end of the label. Optional inputs would then be understood to not have the asterisk. If using the asterisk icon, do not leave any space between the label text and the start of the `<svg>` element in the markup. Extra space should not be added in addition to the inline margin.
*
* The field label for a required field can display either the text “(required)”, or an asterisk.
*
* When marking a field as required, a word-joiner character (e.g. `U+2060` or `&#8288;`) should be placed between the label text and the required marker to prevent the marker from appearing on its own line.
*/
export const Required = Template.bind({});
Required.args = {
Expand Down
3 changes: 1 addition & 2 deletions components/fieldlabel/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ export const Template = ({
data-testid=${ifDefined(testId)}
for=${ifDefined(forInput)}
>
${label}
${when(isRequired, () => icon)}
${label?.trim()}${when(isRequired, () => html`&#8288;${icon}`)}
</label>
`;
};
Loading