File tree Expand file tree Collapse file tree 8 files changed +110
-2
lines changed
uui-ref-node-data-type/lib
uui-ref-node-document-type/lib Expand file tree Collapse file tree 8 files changed +110
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ import { html } from 'lit';
44import type { Meta , StoryObj } from '@storybook/web-components-vite' ;
55import { renderSlots , spread } from '../../../storyhelpers' ;
66
7+ const setFocus = ( ) => {
8+ const refElement = document . querySelectorAll ( '#refNode' ) ;
9+ refElement [ 0 ] . focus ( ) ;
10+ } ;
11+
712const meta : Meta = {
813 id : 'uui-ref-node-data-type' ,
914 component : 'uui-ref-node-data-type' ,
@@ -66,3 +71,11 @@ export const Readonly: Story = {
6671 readonly : true ,
6772 } ,
6873} ;
74+
75+ export const Focus : Story = {
76+ render : args =>
77+ html `< uui-ref-node-document-type id ="refNode " ${ spread ( args ) }
78+ > ${ renderSlots ( args ) } </ uui-ref-node-document-type
79+ >
80+ < button @click =${ ( ) => setFocus ( ) } > Set focus</ button > ` ,
81+ } ;
Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ import { html } from 'lit';
44import type { Meta , StoryObj } from '@storybook/web-components-vite' ;
55import { renderSlots , spread } from '../../../storyhelpers' ;
66
7+ const setFocus = ( ) => {
8+ const refElement = document . querySelectorAll ( '#refNode' ) ;
9+ refElement [ 0 ] . focus ( ) ;
10+ } ;
11+
712const meta : Meta = {
813 id : 'uui-ref-node-document-type' ,
914 component : 'uui-ref-node-document-type' ,
@@ -13,9 +18,13 @@ const meta: Meta = {
1318 alias : 'productPage' ,
1419 } ,
1520 render : args =>
16- html `< uui-ref-node-document-type ${ spread ( args ) }
21+ html `< uui-ref-node-document-type
22+ id ="refNode "
23+ ${ spread ( args ) }
24+ @open =${ ( ) => onOpen ( ) }
1725 > ${ renderSlots ( args ) } </ uui-ref-node-document-type
18- > ` ,
26+ > ` ,
27+
1928 decorators : [
2029 ( Story : any ) => html `< div style ="max-width: 420px; "> ${ Story ( ) } </ div > ` ,
2130 ] ,
@@ -66,3 +75,11 @@ export const Readonly: Story = {
6675 readonly : true ,
6776 } ,
6877} ;
78+
79+ export const Focus : Story = {
80+ render : args =>
81+ html `< uui-ref-node-document-type id ="refNode " ${ spread ( args ) }
82+ > ${ renderSlots ( args ) } </ uui-ref-node-document-type
83+ >
84+ < button @click =${ ( ) => setFocus ( ) } > Set focus</ button > ` ,
85+ } ;
Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ import { html } from 'lit';
44import type { Meta , StoryObj } from '@storybook/web-components-vite' ;
55import { renderSlots , spread } from '../../../storyhelpers' ;
66
7+ const setFocus = ( ) => {
8+ const refElement = document . querySelectorAll ( '#refNode' ) ;
9+ refElement [ 0 ] . focus ( ) ;
10+ } ;
11+
712const meta : Meta = {
813 id : 'uui-ref-node-form' ,
914 component : 'uui-ref-node-form' ,
@@ -66,3 +71,11 @@ export const Readonly: Story = {
6671 readonly : true ,
6772 } ,
6873} ;
74+
75+ export const Focus : Story = {
76+ render : args =>
77+ html `< uui-ref-node-document-type id ="refNode " ${ spread ( args ) }
78+ > ${ renderSlots ( args ) } </ uui-ref-node-document-type
79+ >
80+ < button @click =${ ( ) => setFocus ( ) } > Set focus</ button > ` ,
81+ } ;
Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ import { html } from 'lit';
44import type { Meta , StoryObj } from '@storybook/web-components-vite' ;
55import { renderSlots , spread } from '../../../storyhelpers' ;
66
7+ const setFocus = ( ) => {
8+ const refElement = document . querySelectorAll ( '#refNode' ) ;
9+ refElement [ 0 ] . focus ( ) ;
10+ } ;
11+
712const meta : Meta = {
813 id : 'uui-ref-node-member' ,
914 component : 'uui-ref-node-member' ,
@@ -66,3 +71,12 @@ export const Readonly: Story = {
6671 readonly : true ,
6772 } ,
6873} ;
74+
75+ export const Focus : Story = {
76+ render : args =>
77+ html `< uui-ref-node-member id ="refNode " ${ spread ( args ) }
78+ > ${ renderSlots ( args ) } </ uui-ref-node-document-type
79+ >
80+ < button @click =${ ( ) => setFocus ( ) } > Set focus</ button >
81+ ` ,
82+ } ;
Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ import { html } from 'lit';
44import type { Meta , StoryObj } from '@storybook/web-components-vite' ;
55import { renderSlots , spread } from '../../../storyhelpers' ;
66
7+ const setFocus = ( ) => {
8+ const refElement = document . querySelectorAll ( '#refNode' ) ;
9+ refElement [ 0 ] . focus ( ) ;
10+ } ;
11+
712const meta : Meta = {
813 id : 'uui-ref-node-package' ,
914 component : 'uui-ref-node-package' ,
@@ -67,3 +72,11 @@ export const Readonly: Story = {
6772 readonly : true ,
6873 } ,
6974} ;
75+
76+ export const Focus : Story = {
77+ render : args =>
78+ html `< uui-ref-node-package id ="refNode " ${ spread ( args ) }
79+ > ${ renderSlots ( args ) } </ uui-ref-node-package
80+ >
81+ < button @click =${ ( ) => setFocus ( ) } > Set focus</ button > ` ,
82+ } ;
Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ import { html } from 'lit';
44import type { Meta , StoryObj } from '@storybook/web-components-vite' ;
55import { renderSlots , spread } from '../../../storyhelpers' ;
66
7+ const setFocus = ( ) => {
8+ const refElement = document . querySelectorAll ( '#refNode' ) ;
9+ refElement [ 0 ] . focus ( ) ;
10+ } ;
11+
712const meta : Meta = {
813 id : 'uui-ref-node-user' ,
914 component : 'uui-ref-node-user' ,
@@ -66,3 +71,12 @@ export const Readonly: Story = {
6671 readonly : true ,
6772 } ,
6873} ;
74+
75+ export const Focus : Story = {
76+ render : args =>
77+ html `< uui-ref-node-user id ="refNode " ${ spread ( args ) }
78+ > ${ renderSlots ( args ) } </ uui-ref-node-package
79+ >
80+ < button @click =${ ( ) => setFocus ( ) } > Set focus</ button >
81+ ` ,
82+ } ;
Original file line number Diff line number Diff line change @@ -163,6 +163,11 @@ export class UUIRefNodeElement extends UUIRefElement {
163163 ` ;
164164 }
165165
166+ public focus ( ) {
167+ const openPart = this . renderRoot . querySelector ( '#open-part' ) as HTMLElement ;
168+ openPart ?. focus ( ) ;
169+ }
170+
166171 #renderOpenPart( ) {
167172 if ( this . readonly ) {
168173 return html `${ this . #renderContent( ) } ` ;
@@ -228,6 +233,10 @@ export class UUIRefNodeElement extends UUIRefElement {
228233 }
229234 }
230235
236+ .test {
237+ border : red 10px ;
238+ }
239+
231240 : host (: not ([disabled ])) # open-part : hover # icon {
232241 color : var (--uui-color-interactive-emphasis );
233242 }
Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ import '@umbraco-ui/uui-action-bar/lib';
99import '@umbraco-ui/uui-button/lib' ;
1010import '@umbraco-ui/uui-icon/lib' ;
1111
12+ const setFocus = ( ) => {
13+ const refElement = document . querySelectorAll ( '#refNode' ) ;
14+ console . log ( refElement [ 0 ] ) ;
15+ refElement [ 0 ] . focus ( ) ;
16+ } ;
17+
1218const meta : Meta = {
1319 id : 'uui-ref-node' ,
1420 component : 'uui-ref-node' ,
@@ -79,3 +85,12 @@ export const Readonly: Story = {
7985 readonly : true ,
8086 } ,
8187} ;
88+
89+ export const Focus : Story = {
90+ render : args =>
91+ html `< uui-ref-node id ="refNode " ${ spread ( args ) }
92+ > ${ renderSlots ( args ) } </ uui-ref-node-package
93+ >
94+ < button @click =${ ( ) => setFocus ( ) } > Set focus</ button >
95+ ` ,
96+ } ;
You can’t perform that action at this time.
0 commit comments