Skip to content
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: Improve text wrapping in dropdown error messages #1469

Merged
merged 4 commits into from
Sep 19, 2023
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
2 changes: 1 addition & 1 deletion src/__integ__/page-objects/async-dropdown-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class AsyncDropdownComponentPage extends AsyncDropdownPage {
if (!exists) {
return null;
}
return this.getText(statusIndicatorSelector);
return this.getText(statusIndicatorSelector).then(value => value.trim());
}

async assertStatusText(expected: string | null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function renderComponent(props: DropdownStatusPropsExtended) {
const wrapper = createWrapper(container!);
return {
getStickyState: () => getByTestId('sticky-state').textContent,
getContent: () => getByTestId('content').textContent,
getContent: () => getByTestId('content').textContent?.trim(),
getIcon: () => wrapper.findStatusIndicator()!.findByClassName(statusIconStyles.icon)!.getElement(),
};
}
Expand Down
10 changes: 2 additions & 8 deletions src/internal/styles/utils/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@
// prevents the text wrapping. We need to override the min-width by setting it to "0"
min-width: 0;

// IE does not support `word-break: break-word`.
// We use `-ms-word-break: break-all` as a compromise for IE.
-ms-word-break: break-all;

// From docs:
// > To prevent overflow, an otherwise unbreakable string of characters — like a long word or URL — may be broken at
// > any point if there are no otherwise-acceptable break points in the line.
// Also, this overrides any usage of `overflow-wrap` (and its alias `word-wrap`). Therefore, such rule is not used.
// `word-break: break-word` is deprecated.
// But its replacement, `overflow-wrap: anywhere`, is not supported in Safari 14.0 and 15.0.
word-break: break-word;
}

Expand Down
1 change: 1 addition & 0 deletions src/status-indicator/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default function StatusIndicator({
role={iconAriaLabel ? 'img' : undefined}
>
{typeToIcon(__size)[type]}
{__display === 'inline' && <>&nbsp;</>}
</span>
{children}
</span>
Expand Down
18 changes: 11 additions & 7 deletions src/status-indicator/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,24 @@ $_color-overrides: (
}
}

.icon {
padding-right: awsui.$space-xxs;
}

.container {
word-break: break-all;
word-wrap: break-word;

&.display-inline {
@include styles.text-wrapping;
display: inline;

> .icon {
white-space: nowrap;
}
}

&.display-inline-block {
display: inline-block;
word-wrap: break-word;
word-break: break-all;
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd love to do this for all status indicators, but it feels like way too big and scary a change to make for all status indicators.


> .icon {
padding-right: awsui.$space-xxs;
}
}
}

Expand Down
Loading