-
Notifications
You must be signed in to change notification settings - Fork 33
GAUD-10291 - Fix issue where focusing the divider causes a page scroll #7221
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
Changes from all commits
74227d8
c41c7dd
c97a9e0
993c569
674867b
edfbc5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,28 +57,39 @@ class PageDivider extends FocusMixin(PropertyRequiredMixin(LitElement)) { | |
| background-color: var(--d2l-color-gypsum); | ||
| cursor: ew-resize; | ||
| height: 100%; | ||
| outline: none; | ||
| position: relative; | ||
| width: ${DIVIDER_WIDTH}px; | ||
| } | ||
| .divider:hover { | ||
| background-color: var(--d2l-color-mica); | ||
| } | ||
| .divider:focus { | ||
| .divider:focus-within { | ||
| background-color: var(--d2l-color-celestine); | ||
| } | ||
|
|
||
| .slider { | ||
| outline: none; | ||
| position: absolute; | ||
| top: 55px; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be (or will wrap) the collapse button, but just adding the minimum pieces right now to get the defect fixed and the vdiffs in place to protect from regressions. |
||
| } | ||
|
|
||
| :host([panel-type="drawer"]) .divider { | ||
| background-color: var(--d2l-color-celestine); | ||
| cursor: ns-resize; | ||
| height: ${DIVIDER_WIDTH}px; | ||
| width: 100%; | ||
| } | ||
|
|
||
| :host([panel-type="drawer"]) .slider { | ||
| inset-inline-end: 18px; | ||
| top: auto; | ||
| } | ||
|
|
||
| /* TO DO: Lots more divider styling to come */ | ||
|
|
||
| `; | ||
|
|
||
| static focusElementSelector = '.divider'; | ||
| static focusElementSelector = '.slider'; | ||
|
|
||
| constructor() { | ||
| super(); | ||
|
|
@@ -98,17 +109,19 @@ class PageDivider extends FocusMixin(PropertyRequiredMixin(LitElement)) { | |
| } | ||
|
|
||
| return html` | ||
| <div | ||
| class="divider" | ||
| role="slider" | ||
| tabindex="0" | ||
| aria-label="${this.label}" | ||
| aria-orientation="${this.panelType === 'panel' ? 'horizontal' : 'vertical'}" | ||
| aria-valuemax="${ifDefined(ariaValues.max)}" | ||
| aria-valuemin="${ifDefined(ariaValues.min)}" | ||
| aria-valuenow="${ifDefined(ariaValues.now)}" | ||
| aria-valuetext="${ifDefined(ariaValues.text)}" | ||
| @keydown="${this.#handleKeyDown}"> | ||
| <div class="divider" @pointerdown="${this.#handlePointerDown}"> | ||
| <div | ||
| class="slider" | ||
| role="slider" | ||
| tabindex="0" | ||
| aria-label="${this.label}" | ||
| aria-orientation="${this.panelType === 'panel' ? 'horizontal' : 'vertical'}" | ||
| aria-valuemax="${ifDefined(ariaValues.max)}" | ||
| aria-valuemin="${ifDefined(ariaValues.min)}" | ||
| aria-valuenow="${ifDefined(ariaValues.now)}" | ||
| aria-valuetext="${ifDefined(ariaValues.text)}" | ||
| @keydown="${this.#handleKeyDown}"> | ||
| </div> | ||
| </div> | ||
| `; | ||
| } | ||
|
|
@@ -148,6 +161,11 @@ class PageDivider extends FocusMixin(PropertyRequiredMixin(LitElement)) { | |
| this.#sendResizeEvent(requestedSize); | ||
| } | ||
|
|
||
| #handlePointerDown(e) { | ||
| e.preventDefault(); | ||
| this.focus(); | ||
| } | ||
|
|
||
| #sendResizeEvent(requestedSize) { | ||
| const clampedRequestedSize = clampedSize(requestedSize, this.minSize, this.maxSize); | ||
| /** @ignore */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { createDivider, getSlider } from './page-divider-internal-fixtures.js'; | ||
| import { expect, fixture, html, nextFrame, oneEvent, runConstructor, sendKeysElem } from '@brightspace-ui/testing'; | ||
| import { KEYBOARD_STEP, KEYBOARD_STEP_LARGE } from '../page-divider-internal.js'; | ||
| import { createDivider } from './page-divider-internal-fixtures.js'; | ||
|
|
||
| describe('d2l-page-divider-internal', () => { | ||
|
|
||
|
|
@@ -11,7 +11,7 @@ describe('d2l-page-divider-internal', () => { | |
| describe('accessibility', () => { | ||
| it('calculates aria values correctly', async() => { | ||
| const elem = await fixture(html`<d2l-page-divider-internal label="Resize" min-size="100" max-size="200" current-size="150"></d2l-page-divider-internal>`); | ||
| const slider = elem.shadowRoot.querySelector('.divider'); | ||
| const slider = getSlider(elem); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made this function so the update in this PR would be cleaner, and then forgot to use it 🤦♀️ |
||
| expect(slider.getAttribute('aria-valuemax')).to.equal('200'); | ||
| expect(slider.getAttribute('aria-valuemin')).to.equal('0'); | ||
| expect(slider.getAttribute('aria-valuenow')).to.equal('150'); | ||
|
|
@@ -20,7 +20,7 @@ describe('d2l-page-divider-internal', () => { | |
|
|
||
| it('does not set aria values when in unknown state', async() => { | ||
| const elem = await fixture(html`<d2l-page-divider-internal label="Resize"></d2l-page-divider-internal>`); | ||
| const slider = elem.shadowRoot.querySelector('.divider'); | ||
| const slider = getSlider(elem); | ||
| expect(slider.hasAttribute('aria-valuemax')).to.be.false; | ||
| expect(slider.hasAttribute('aria-valuemin')).to.be.false; | ||
| expect(slider.hasAttribute('aria-valuenow')).to.be.false; | ||
|
|
||
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.
Unrelated, but was driving me crazy