Patternfly-react: Select group label not required, but without label it breaks the UI

Created on 25 Jun 2020  路  5Comments  路  Source: patternfly/patternfly-react

Describe the issue. What is the expected and unexpected behavior?

When using select with SelectGroup the label is marked as optional, yet if I don't pass it it breaks the whole UI with error message Uncaught (in promise) TypeError: Cannot read property 'replace' of undefined

Please provide the steps to reproduce. Feel free to link CodeSandbox or another tool.
Remove label in PF examples and it breaks the component.

Is this a bug or enhancement? If this issue is a bug, is this issue blocking you or is there a work-around?
Rather critical bug, we can't properly upgrade to new PF because of this bug.

What is your product and what release version are you targeting?
cloud.redhat.com

PF4 bug

Most helpful comment

+1 adding the null check

Making it required would be breaking, and I'm not sure it needs to be required. It definitely needs to not break when left out though

All 5 comments

ping @tlabaj @redallen

The bug is caused by this https://github.com/patternfly/patternfly-react/blob/master/packages/react-core/src/components/Select/SelectMenu.tsx#L64 Is there any reasonable reason why changing the groupLabel? If I'd send + as group label this would have been changed - I was searching trough the codebase and it looks like the property titleId is not used anywhere. Might be a leftover and could be removed.

It's used in SelectGroup.tsx:

<div className={css(styles.selectMenuGroupTitle)} id={titleId} aria-hidden>

I'm unfamiliar with how SelectGroup works. We should make the prop required or change the code to group.props.label && group.props.label.replace(/\W/g, '-'),.

cc @kmcfaul

+1 adding the null check

Making it required would be breaking, and I'm not sure it needs to be required. It definitely needs to not break when left out though

@kmcfaul thank you for the fix!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rudi3 picture Rudi3  路  7Comments

Hyperkid123 picture Hyperkid123  路  6Comments

seanforyou23 picture seanforyou23  路  6Comments

andrewballantyne picture andrewballantyne  路  4Comments

priley86 picture priley86  路  3Comments