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

[Feature Request]: white-space style will be override for items under ButtonDropdown #1960

Open
2 tasks done
franky920920 opened this issue Feb 13, 2024 · 5 comments
Open
2 tasks done
Labels
enhancement New feature or request

Comments

@franky920920
Copy link

franky920920 commented Feb 13, 2024

Description

The ButtonDropdown component's item will not wrap text if you have a white-space property set and rides on it.

For me, its because I have

* {
  white-space: break-spaces;
}

set globally. (for line break \n in i18n strings)


My workaround: add custom className, for example buttonDropdownFix (I know this is discouraged but like I said, its a workaround), and have css like

.buttonDropdownFix ul > li > span {
    white-space: nowrap;
}

Please let me know if any questions. Thanks!

All opinions are my own.

Code of Conduct

@franky920920 franky920920 added the enhancement New feature or request label Feb 13, 2024
@franky920920 franky920920 changed the title [Feature Request]: Option to not wrap text on ButtonDropdown item [Feature Request]: white-space style will be override for items under ButtonDropdown Feb 13, 2024
@just-boris
Copy link
Member

If we start looking into this issue, we should support it for all components, not just dropdown. How do you expect this to work? How do we distinguish "good" i18n strings (which should follow your selector) and "bad" (which should not)?

Can you make your * selector more specific to strings that you certainly know should have this wrapping?

@franky920920
Copy link
Author

Hi @just-boris,
(Found typo in issue, edited)

I expect all components has its own css property instead of inheriting from its parent.

In my use case, our i18n strings may contains \n characters to determinate line break in different languages, like the example below:

// en/translation.json
{
  "demo_string": "This is a long line of description and requires \n link breaks."
}

If we don't have white-space: break-spaces; set, the \n for line break won't work like expected, but one its set, it might break Cloudscape component like ButtonDropdown here:

unexpected

image

expected

image

@just-boris
Copy link
Member

just-boris commented Feb 14, 2024

So if you put a <Header description={i18nStrings.demo_string}> you expect this to respect line breaks. But if you put the very same string inside <ButtonDropdown items={[{text: i18nStrings.demo_string}]}> you expect line breaks to be ignored.

How do you make sense of this request?

@franky920920
Copy link
Author

Sorry I think my previous description were not clear, so let me clear this again.

Assuming I have a translation file like this:

{
  "string_for_box": "This is a long line of description and requires \n link breaks.",
  "string_for_actionButton": "Actions",
  "string_for_actionButton_a": "This is a long item without line break"
}

For <Box>{i18n.string_for_box}</Box>, I DO expect a line break here as I put a \n in i18n strings indicating I want a line wrap, so I put white-space: break-spaces styles on * selector to make \n break the lines.

But for

<ButtonDropdown item={[text: i18n.string_for_actionButton_a]}>
  i18n.string_for_actionButton
</Box>

I DO NOT expect any string being wrapped like this screenshot as I didn't put any \n in these strings.
image

Hope this make the issue clear. Sorry for the bad description previously.

@just-boris
Copy link
Member

So you want <Box> component to wrap and <ButtonDropdown> not to wrap.

What should we do if tomorrow we get another customer requesting the exact opposite behavior? How are we supposed to support both cases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants