-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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(CodeSnippet): set number of closed and open rows #7826
fix(CodeSnippet): set number of closed and open rows #7826
Conversation
add closedNumberOfRows and expandedNumberOfRows props set mixin max-height using closedMaxHeight and expandedMaxHeight determine show button visibility using closed/expanded NumberOfRows sort consts and prop
Deploy preview for carbon-elements ready! Built with commit c7ba1bf |
Deploy preview for carbon-components-react ready! Built without sensitive environment variables with commit c7ba1bf https://deploy-preview-7826--carbon-components-react.netlify.app |
add new CodeSnippet props to Storybook
…umber-of-closed-and-open-rows
Part of the fix will be to pass a variable from the CodeSnippet React class to the the CodeSnippet mixin (the PR has both these working independently). Anyone have guidance on how to do this or of an existing example where this is being done? Update: So now the questions are...
I rewrote the code to set height via style. |
Question about button positions. .#{$prefix}--snippet--multi .#{$prefix}--copy-btn { |
I believe the |
I can't seem to get this to work as I understand it should in Firefox on Windows 10 Clicking show/hide shows or hides rows that don't contain code. Also worth noting is I can select negative rows in the playground addons panel for this. |
remove minHeight/maxHeight from scss rework overflow settings to allow x and y scrolling updated stories to allow knobs in all variations updated knobs to include all the props updated stories to show props not ...args in docs added min/max closed/expanded props to CodeSnippet changed rowHeight from 18 to 16, changing rows showed I was off a little update shouldShowMoreLessBtn dynamically if data changes update expandedCode dynamically if data changes add minHeight/maxHeight styles to snippet-container add PropTypes for the new props BREAKING CHANGE: expand is set to 30 rows from unlimited
…umber-of-closed-and-open-rows
With the latest commit I think I'm able to take the Draft tag off this PR now. There is still a glitch with the overflow indicators (the shading of characters to indicate scrollable content left and right) but I'm hoping to discuss this and remove the indicators. @dakahn mentioned that the playground values can be negative. On this note unexpected things may happen if users try to set the min/max closed/expanded to odd numbers...
|
updated snapshot added {min=1} governer to Storybook numbers
I tested this on Mac and Win10, and updated the description to show this. |
I did some testing on windows. ie: if overflow:scroll is set you will get x and y scrollbars on windows regardless of the data. |
On platforms when the scrollbars always shows, this change will remove the horizontal srollbar when wrapText=true as we will never need it
…umber-of-closed-and-open-rows
Alphabetical - moved max above min
moved width before overflow set Story defaults to match CodeSnippet defaults
…umber-of-closed-and-open-rows
updated CodeSnippet-story copyright year added missed component- in the id when merging code
The negative numbers aren't a blocker, just worth mentioning in case someone with some Storybook experience knew a quick fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested NVDA with Firefox and JAWS with Edge/Chrome on Windows 10
A couple of notes:
- In JAWS latest and NVDA the Show More button's label is being read twice as "Show more, show more button", could be some unneeded aria causing this.
- In Edge/Chrome the scrolling content in not keyboard accessible
- the horizontal scrolling is a violation of WCAG 1.4.10. The code snippet should reflow down the page and not require scrolling in two dimensions.
hideCopyButton: boolean('Hide copy button (hideCopyButton)', false), | ||
const typeOptions = { | ||
inline: { inline: 'inline' }, | ||
single: { single: 'single' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why we're changing all these storybook lines? This is adding quite a bit of bloat to the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most - not all - of the props were defined in the const props.
Deconstructing the const props in a story shows the props it contains in the stories knobs.
The stories code was then limited - not showing the props used to create it but props deconstructed {...props}
and the stories knobs shows props unrelated to the variant it was describing.
To make the Stories more clear I wanted to show the specific props used by each variant.
Initially I created four (inline/single/multi/skeleton) consts but found there was a lot of duplicate code.
So I created one const for each prop and have each variant deconstruct the props uses.
This - in my view - is cleaner and will allow for further Stories to be easily created.
I'm ok with going back to one uber const that contains all props.
But if we do, I would suggest we have only one Story(Playground) that uses it.
Have the other Stories code the exact props it uses, so the users can see what is being used/set to create the Story.
maxClosedNumberOfRows: number( | ||
'maxClosedNumberOfRows: Specify the maximum number of rows to be shown when in closed view', | ||
15, | ||
{ min: 1 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this as a comment on the code so any discussion about it can be kept in a thread.
From @dakahn
It is worth noting is I can select negative rows in the playground addons panel for this.
The negative numbers aren't a blocker, just worth mentioning in case someone with some Storybook experience knew a quick fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the one hand we may want Storybook to be user friendly and only allow what the user should enter.
Towards this I added 'min' entry, and would like to add 'scale' and maybe coded limiters...
On the other hand we may want Storybook to accept anything the user may pass to the Component.
This way we can dup problems, and/or test that bad values are handled properly.
I see both sides, I'm torn (but lean towards leaving it open), but will do whatever Carbon wants.
showLessText = defaultShowLessText, | ||
showMoreText = defaultShowMoreText, | ||
type = defaultType, | ||
wrapText = defaultWrapText, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this as a comment on the code so any discussion about it can be kept in a thread.
From @dakahn
Tested NVDA with Firefox and JAWS with Edge/Chrome on Windows 10
A couple of notes:
In JAWS latest and NVDA the Show More button's label is being read twice as "Show more, show more button", could be some unneeded aria causing this.
In Edge/Chrome the scrolling content in not keyboard accessible
the horizontal scrolling is a violation of WCAG 1.4.10. The code snippet should reflow down the page and not require scrolling in two dimensions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first two issues were not introduced (they existed before).
I didn't notice them and will try to fix them, if this PR doesn't get scrapped because of WCAG 1.4.10.
Humm, I have now did a little reading on WCAG 1.4.10 and have a little knowledge (so I'm a danger to myself and others).
If CodeSnippet is to be WCAG 1.4.10 compliant and not be except by falling into the category of 'content which requires two-dimensional layout for usage or meaning cannot reflow without losing meaning' then I think we have more to discuss.
Things like...
- the wrapText prop should be deprecated and wrapText is always TRUE
- wrapText can not simply be a break on whitespace, it will need to understand content breaks
- we need props to help us understand what we are displaying to determine how to display it
-- we need to know if its a horizontal or vertical locale, to determine which way to scroll
-- we need to know if its a LTR or RTL locale, to determine if we start left or right justified - there may be more
What is the next step to discussing this?
Who do we need to get involved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first issue was previously present. I'll open a ticket to track.
The second issue -- scrolling is not keyboard accessible -- isn't present for me in prod because I have no scrollbars whatsoever when code is hidden (which is another problem altogether).
There could be something i'm misunderstanding here, but if your feature introduces scrollbars on Windows they need to be keyboard accessible.
To be 1.4.10 compliant we need to maintain the text reflow we currently have in prod seen here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as for things like wrapText
-- as long as the out-of-the-box experience meets WCAG requirements we can document the problems with props that cause violations and we're good as far as v10 is concerned. We can look into deprecating wrapText
in future versions though for sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, when hidden there is no scrollbar - but you can still scroll - which is one of the problems I was trying to address.
You can, In prod, end up with two way scrolling; if wrapText=false and the CodeSnippet has enough rows you do get two scrollbars.
One is on the CodeSnippet and one is on the container the snippet is in.
I made the issue much easier to encounter by enabling vertical scrolling and always showing the horizontal scrolling.
The existing issues, and my changes effect any OS, not just windows.
double.scrolling.mov
Don't get me wrong, I understand my solution is not 1.4.10 compliant.
I just think to be 1.4.10 compliant more discussion is needed on the points I made earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, as the issue is simply an issue with two scrollbars.
So isn't the solution - at least for horizontal LTR languages to disallow wrapText?
This would allow only the vertical scrollbar and therefor be 1.4.10 compliant.
We still have to deal with...
- horizontal RTL latin languages - which should start right justified
- vertical languages - which should only have a vertical scroll bar
- and a proper wrapText to ensure we are breaking in correct places
@guigueb thanks for contributing this. It seems like there are some design changes here that weren't discussed in the original issue and might be out of scope for this PR. I'm mainly referring to some of the padding/spacing changes made, which as you noted, hide some of the code snippet content even when expanded. This is why we have the padding on there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the scope of the PR to just the min/max row functionality, no other design changes until they've been approved by our designers in the issue.
I think I only made one padding related change... which I was told to do by @laurenmrice in PR7582. Fixing the scrolling functionality is needed, currently CodeSnippet is not useable with large data. At this point I think we either need to flush out 1.4.10 compliant-ness now or live with this and address 1.4.10 compliant later. I may be wrong but I don't think I changed anything else. To be clear: |
@guigueb I think Josefina is just pointing out that this may need to break into several smaller PR's, with a defined scope for each. I would not expect a PR adding in a change for the number of rows shown when opened/closed to contain almost 500 line changes. I think to achieve this functionality we need to:
Basically, the existing user experience should not change for an end-user unless they opt into adding the two new props. |
Looks like I closed this PR.. it was not my intention, I must have hit the wrong button. I have created smaller enhancement issues, listed below, that this PR can be broken up to address. #7579 CodeSnippet: there should be a way to set the number of rows when in closed and expanded mode |
Side note: about 400 lines of this change are to make the stories more intractable and explanatory to the user. |
I also logged #8059 to address the overflow indicator issue. |
remove minHeight/maxHeight from scss
rework overflow settings to allow x and y scrolling
updated stories to allow knobs in all variations
updated knobs to include all the props
updated stories to show props not ...args in docs
added min/max closed/expanded props to CodeSnippet
changed rowHeight from 18 to 16, changing rows showed I was off a little
update shouldShowMoreLessBtn dynamically if data changes
update expandedCode dynamically if data changes
add minHeight/maxHeight styles to snippet-container
add PropTypes for the new props
BREAKING CHANGE: expand is set to 30 rows from unlimited
Closes #
#7579
#7574
Tested:
MacOS - Chrome, FireFox, and Safari
Win10 - Chrome, FireFox, and Edge
The behavior is good and as expected ( I think ).
But I did noticed one thing...
This effects two things...
-- on MacOS you see all 5 rows, when scrolling the last row is covered with a transparent scrollbar
-- on Win10 you will see 5 rows if no horizontal scroll is available, but if so the last row will not be seen as it will always have a solid scroll bar covering it
--- I thought of determining the OS and adjusting when scrollable and not scrollable but this would change the size of the CodeSnippet and lead to layout issues. Best to document this behavior as expected.
Questions/confirmations:
I thank TJ for replying about the spacing of the copy button when in multi-mode. Can UX confirm that is the design we want to stick with?
Who needs to discuss the use/keeping of the overflow indicators? They are only applicable on Mac as other OS's show scroll bars, they are only useful when there is something in the visible shade area to be shaded, and the shading is very subtle and easily overlooked.
Since a MAC user is aware/used to hidden scrollbars and have the option of turning them on (https://www.matuzo.at/blog/css-pro-tip-for-mac-users-always-show-scroll-bars-in-macos/) I think the overflow indicators should be removed - optionally we could always force them on for CodeSnippet.