This repository was archived by the owner on Nov 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
src/packages/core/components/split-panel Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,24 @@ export class UmbSplitPanelElement extends LitElement {
222222 this . #connect( ) ;
223223 }
224224
225+ #onKeydown( event : KeyboardEvent ) {
226+ if ( event . key === 'ArrowLeft' || event . key === 'ArrowRight' ) {
227+ const { width } = this . mainElement . getBoundingClientRect ( ) ;
228+ const divider = this . dividerElement . getBoundingClientRect ( ) ;
229+
230+ const dividerPos = divider . left - this . mainElement . getBoundingClientRect ( ) . left ;
231+ const percentageFromWidth = ( dividerPos / width ) * 100 ;
232+
233+ const multiplier = event . shiftKey ? 10 : 1 ;
234+ const step = 1 * multiplier * ( event . key === 'ArrowLeft' ? - 1 : 1 ) ;
235+
236+ const newPercent = percentageFromWidth + step ;
237+ const toPixels = ( newPercent / 100 ) * this . mainElement . getBoundingClientRect ( ) . width ;
238+
239+ this . #setPosition( toPixels ) ;
240+ }
241+ }
242+
225243 render ( ) {
226244 return html `
227245 <div id= "main" >
@@ -230,7 +248,7 @@ export class UmbSplitPanelElement extends LitElement {
230248 @slotchange = ${ this . #onSlotChanged}
231249 style= "width: ${ this . _hasStartPanel ? '100%' : '0' } " > </ slot>
232250 <div id= "divider" >
233- <div id= "divider-touch-area" tabindex = "0" > </ div>
251+ <div id= "divider-touch-area" tabindex = "0" @keydown = ${ this . #onKeydown } > </ div>
234252 </ div>
235253 <slot name= "end" @slotchange = ${ this . #onSlotChanged} style= "width: ${ this . _hasEndPanel ? '100%' : '0' } " > </ slot>
236254 </ div>
You can’t perform that action at this time.
0 commit comments