GAUD-10203 & GAUD-10205 - Add divider, panel state controller and keyboard resizing#7151
Conversation
|
Thanks for the PR! 🎉 We've deployed an automatic preview for this PR - you can see your changes here:
Note The build needs to finish before your changes are deployed. |
| return html` | ||
| <div | ||
| class="divider" | ||
| role="slider" |
There was a problem hiding this comment.
The window splitter pattern says to use the "separator" role, but as far as I can tell that doesn't work at all. This is talked about here - it's not a widget and keyboard and mouse events are just swallowed. So I'm using the "slider" role, as primary-secondary does, and following that pattern.
There was a problem hiding this comment.
Yeah was just reading about that as well, sounds good.
| // TO DO: Maybe we don't bother clamping here, since the panel state controller will clamp it anyway | ||
| const clampedRequestedSize = clampedSize(requestedSize, this.minSize, this.maxSize); |
There was a problem hiding this comment.
Considering removing this - we can clamp early because we have all the info we need. But PanelStateController also has to do this clamping, so it's redundant.
There was a problem hiding this comment.
I don't hate it either, since this component does have a "min" and a "max" it's a little bad if it doesn't adhere to its own setup. 🤷
There was a problem hiding this comment.
Ok, we'll keep it! Removed the comment questioning it
| const MAIN_MIN_WIDTH = 600; // TO DO: Confirm | ||
| const PANEL_MIN_WIDTH = 320; | ||
|
|
||
| class PanelStateController { |
There was a problem hiding this comment.
Went through a few iterations before settling on using a controller here. Simple objects were messy, a Class seemed a bit like overkill by itself, but the controller works really nicely with being able to handle the requested updates smoothly.
| #handleWindowResizeBound; | ||
| #resizeObserver; | ||
|
|
||
| #getMaxDrawerHeight() { |
There was a problem hiding this comment.
So we can't actually test the drawer stuff yet (I might do that as the next PR), but I wanted to make sure it fit into the pattern well. So added some minimal stuff for that - defaults, setting min and max, and reacting to height updates.
dlockhart
left a comment
There was a problem hiding this comment.
This is looking good to me!
| .divider:hover { | ||
| background-color: var(--d2l-color-mica); | ||
| } | ||
| .divider:focus { |
There was a problem hiding this comment.
We probably want :focus-visible here as I'm noticing that when I click on it (even though that isn't supported yet) these styles get applied.
There was a problem hiding this comment.
I asked Glen about this and he wanted it visible, to match primary-secondary, but we can check to confirm. Eventually it'll show arrows that may be helpful to a sighted user, to tell them they've made it as big as it can go 🤷♀️
| * REQUIRED: aria-label for the divider | ||
| * @type {string} | ||
| */ | ||
| label: { type: String }, |
There was a problem hiding this comment.
Probably want to use PropertyRequiredMixin so that this throws if it's missing.
| return html` | ||
| <div | ||
| class="divider" | ||
| role="slider" |
There was a problem hiding this comment.
Yeah was just reading about that as well, sounds good.
| // TO DO: Maybe we don't bother clamping here, since the panel state controller will clamp it anyway | ||
| const clampedRequestedSize = clampedSize(requestedSize, this.minSize, this.maxSize); |
There was a problem hiding this comment.
I don't hate it either, since this component does have a "min" and a "max" it's a little bad if it doesn't adhere to its own setup. 🤷
| <div | ||
| class="divider" | ||
| role="slider" | ||
| tabindex="0" |
There was a problem hiding this comment.
I'm seeing something weird where I can only shift-tab to the divider from the main panel... if I tab from the side nav panel it skips right past it.
There was a problem hiding this comment.
So I'm pretty sure this is a list issue/defect. If you remove d2l-list or put something focusable after the list, it's fine. But I haven't dug in too much yet, maybe I need to do something to the divider for list to consider it an appropriate "next focusable" item.
There was a problem hiding this comment.
Ah I see, yeah likely an issue with getNextFocusable not seeing it.
There was a problem hiding this comment.
Added a story for this, will probably add a broken vdiff for it that it can fix lol
There was a problem hiding this comment.
Is this list in grid mode? I could be wrong but unless it's grid mode (which we don't like), I think d2l-list should just be relying on normal tab focus interaction.
I think there is a known issue with focus order due to a subtle difference in how the browser determines the next focusable vs our focus helpers when moving focus in/out of slotted content. I've only ever seen it in d2l-template-primary-secondary, and it's divider was also part of the scenario. Not sure if it's the same.
There was a problem hiding this comment.
It is in grid mode - all of out "nav" list demos have grid mode on, so I figured that's how we recommend/support it currently?
There was a problem hiding this comment.
We received some feedback that it's unhelpful and sometimes confusing. It has come up a couple times in conversation - at this point I think we're uncertain as to whether we want to keep it since the UX improvement has been questioned, it adds complexity to the code, and presents extra challenges when other component behaviour conflicts inside list items. Having said that, I think it's good to test with both modes since we still support it.
There was a problem hiding this comment.
So anyway... I'd be curious to turn off grid mode on the list for this case, just to see if it makes a difference with the behaviour you are observing. Might help narrow the culprit.
There was a problem hiding this comment.
Yeah good idea, removing grid does fix it
…roller-and-keyboard-resizing # Conflicts: # components/page/page.js # lang/ar.js # lang/ca.js # lang/cy.js # lang/da.js # lang/de.js # lang/en-gb.js # lang/en.js # lang/es-es.js # lang/es.js # lang/fr-fr.js # lang/fr.js # lang/haw.js # lang/hi.js # lang/ja.js # lang/ko.js # lang/mi.js # lang/nl.js # lang/pt.js # lang/sv.js # lang/th.js # lang/tr.js # lang/vi.js # lang/zh-cn.js # lang/zh-tw.js
|
🎉 This PR is included in version 3.267.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
| </nav> | ||
| ${!this._slotVisibility['side-nav'] ? nothing : | ||
| html`<div class="divider"></div>`} | ||
| this.#renderDivider('side-nav', this.localize('components.page.side-nav-divider-label'), 'start')} |
There was a problem hiding this comment.
A test dev on my team pointed out to me that we're getting playwright axe test failures now that the divider is more fleshed out but is outside of a landmark. I don't expect a quick resolution because the page component is in progress, but we thought it'd be worth point out.
Failure: https://test-reporting.d2l.dev/artifacts/Brightspace/playwright-ui-automation/28670352275/1/test/playwright/playwright-report/#?testId=723f70fe57f73a0b2d6e-b0b6d6d674acf2bcb2ba
Our use of the component: https://github.com/Brightspace/communications-hub-ui/blob/2a33e0038edd544d21a6231e560271581f67d8b2/src/components/communications-hub-home.js#L11
There was a problem hiding this comment.
lol but... the divider is literally the thing that separates the two landmarks. 🤦
Thanks Tristan -- at the very least it means we need an axe test here that would have caught this!
There was a problem hiding this comment.
Yeah Mark mentioned this and I was looking a bit on Friday. I'm going to put up a change soon and would be interested if it fixes it. In terms of our axe tests not catching it - I think it might be because we wrap our tests, d2l-page is not the top-level component like it might be in a real LMS usage.
There was a problem hiding this comment.
If there is a jira story to track this issue, we can skip this check in our test and can enable the check once story is complete.
There was a problem hiding this comment.
I'm hopeful it may be fixed as a side effect of https://desire2learn.atlassian.net/browse/GAUD-10269, but that story doesn't need to be fully completed for that to happen. Can I reach out to you or Tristan when the change is in and you can unskip the check and test it?
There was a problem hiding this comment.
Ok, this should be resolved by #7200 with core version 3.270.0. Once you've pulled latest core, can you un-skip the test and let me know if it fixes things for you?
First resizable panels slice! Want to make sure this pattern looks good before fleshing it out more, and will start working on tests.
This PR separates the divider out into its own internal component (followed tab as an example), and adds a lit controller to handle panel state. The responsibility breakdown is:
d2l-page-divider-internalPanelStateControllerd2l-pageIn order to be able to test things, I also added keyboard resizing. Collapsing, dragging, mobile modes, etc will all come later.