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(Select): grouped Select generates invalid HTML #4919

Merged
merged 1 commit into from Oct 2, 2020

Conversation

KKoukiou
Copy link
Collaborator

@KKoukiou KKoukiou commented Oct 1, 2020

Fixes #4917

@patternfly-build
Copy link
Contributor

patternfly-build commented Oct 1, 2020

@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2020

Codecov Report

Merging #4919 into master will increase coverage by 0.00%.
The diff coverage is 75.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4919   +/-   ##
=======================================
  Coverage   52.54%   52.55%           
=======================================
  Files         526      526           
  Lines        9575     9579    +4     
  Branches     3533     3536    +3     
=======================================
+ Hits         5031     5034    +3     
  Misses       3900     3900           
- Partials      644      645    +1     
Flag Coverage Δ
#patternfly4 52.55% <75.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...es/react-core/src/components/Select/SelectMenu.tsx 73.33% <60.00%> (-0.81%) ⬇️
...s/react-core/src/components/Select/SelectGroup.tsx 77.77% <100.00%> (+6.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b10ada4...694e86c. Read the comment docs.

Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

The dividers are not wrapped in an li tag.
I'm a little afraid to comment that, and i don't know if it's invalid HTML or not without looking it up.
If we need to wrap the dividers, we need to make sure that the keyboard interactions still work in the typeahead variants.

redallen
redallen previously approved these changes Oct 1, 2020
</div>
<li {...props} className={css(styles.selectMenuGroupTitle, className)} id={titleId}>
{label}
<ul className={css(styles.selectMenuGroup)} role="listbox">
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should only change that children is wrapped by <ul className={css(styles.selectMenuGroup)} role="listbox">, and leave the outer elements the way they were

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's what the issue description suggests to do, but if you read the specification of what can be child of UL is not contain divs.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul

SelectGroups is direct child of UI, and should not contain any divs in other words.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The DOM should look similar to this (copied from Core example):
Screen Shot 2020-10-01 at 1 43 16 PM

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also the changes break the styling a bit, additional indentation etc
https://patternfly-react-pr-4919.surge.sh/components/select#grouped-checkbox-input

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ack I see it now in the HTML docs. I will adjust it tomorrow.
Thanks for the review.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wonder if it's a concious decision though that nested ul li were not used in the HTML docs.

For me it makes sense that the outer items would be also a list (ul) since there indeed part of a list.

@mcarrano I guess you can answer this one :) For example this https://patternfly-react-pr-4919.surge.sh/components/select/#grouped-single

Copy link
Member

Choose a reason for hiding this comment

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

@mcoker can you answer the question above?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jschuler is right with the screenshot posted above. I left the same basic comment here - #4919 (comment)

FWIW you can find the same basic structure in the dropdown, or any menu with groups/titles https://www.patternfly.org/v4/components/dropdown/react/with-groups/

div/section.section
    div/h1-h6.section-title
    ul
        li
        li
        ....

@KKoukiou
Copy link
Collaborator Author

KKoukiou commented Oct 1, 2020

The dividers are not wrapped in an li tag.
I'm a little afraid to comment that, and i don't know if it's invalid HTML or not without looking it up.
If we need to wrap the dividers, we need to make sure that the keyboard interactions still work in the typeahead variants.

Good catch, it's essentially the same problem, do you want me to fix it within this PR, on send another one?
(this fix is a standalone so I suggest to not block it on fixing more things)

jschuler
jschuler previously approved these changes Oct 2, 2020
Copy link
Collaborator

@jschuler jschuler left a comment

Choose a reason for hiding this comment

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

LGTM

ul element can only have li's as children.

Fixes patternfly#4917
@KKoukiou
Copy link
Collaborator Author

KKoukiou commented Oct 2, 2020

LGTM

I needed to rebase - had merge conflicts. Sorry :(

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

lgtm! 🤩

@redallen redallen merged commit 9986d51 into patternfly:master Oct 2, 2020
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • @patternfly/react-catalog-view-extension@4.8.53
  • @patternfly/react-core@4.60.2
  • @patternfly/react-datetime@4.1.2
  • @patternfly/react-docs@5.10.2
  • @patternfly/react-inline-edit-extension@4.5.109
  • demo-app-ts@4.47.2
  • @patternfly/react-table@4.18.6
  • @patternfly/react-topology@4.6.18
  • @patternfly/react-virtualized-extension@4.5.98

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid HTML in grouped menus
9 participants