Commit d3b4db9 1 parent d225b81 commit d3b4db9 Copy full SHA for d3b4db9
File tree 3 files changed +25
-5
lines changed
resources/META-INF/resources/frontend
test/java/org/vaadin/tinymce
3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -241,10 +241,8 @@ public void focus() {
241
241
// Dialog has timing issues...
242
242
getElement ().executeJs ("""
243
243
const el = this;
244
- const isInShadowRoot = document.body.contains(el);
245
- if(isInShadowRoot) {
244
+ if(el.$connector.isInDialog()) {
246
245
setTimeout(() => {
247
- debugger;
248
246
el.$connector.focus()
249
247
}, 150);
250
248
} else {
Original file line number Diff line number Diff line change @@ -34,8 +34,19 @@ window.Vaadin.Flow.tinymceConnector = {
34
34
readonlyTimeout = setTimeout ( ( ) => {
35
35
this . editor . mode . set ( enabled ? 'design' : 'readonly' ) ;
36
36
} , 20 ) ;
37
+ } ,
38
+ isInDialog : function ( ) {
39
+ let inDialog = false ;
40
+ let parent = c . parentElement ;
41
+ while ( parent != null ) {
42
+ if ( parent . tagName . toLowerCase ( ) . indexOf ( "vaadin-dialog" ) == 0 ) {
43
+ inDialog = true ;
44
+ break ;
45
+ }
46
+ parent = parent . parentElement ;
47
+ }
48
+ return inDialog ;
37
49
}
38
-
39
50
} ;
40
51
}
41
52
@@ -83,6 +94,18 @@ window.Vaadin.Flow.tinymceConnector = {
83
94
c . dispatchEvent ( event ) ;
84
95
} ) ;
85
96
97
+ if ( c . $connector . isInDialog ( ) ) {
98
+ // This is inside a shadowroot (Dialog in Vaadin)
99
+ // and needs some hacks to make this nagigateable with keyboard
100
+ if ( ! c . tabIndex ) {
101
+ // make the wrapping element also focusable
102
+ c . setAttribute ( "tabindex" , 0 ) ;
103
+ }
104
+ // on focus to wrapping element, pass forward to editor
105
+ c . addEventListener ( "focus" , e => {
106
+ ed . focus ( ) ;
107
+ } ) ;
108
+ }
86
109
} ;
87
110
88
111
ta . innerHTML = initialContent ;
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ public class PreserveOnRefreshBug27 extends VerticalLayout {
16
16
public PreserveOnRefreshBug27 () {
17
17
Dialog dialog = new Dialog ();
18
18
TinyMce tinyMce = new TinyMce ();
19
- tinyMce .setTabIndex (1 );
20
19
tinyMce .configure ("branding" , false );
21
20
tinyMce .configure ("statusbar" , false );
22
21
tinyMce .setValue ("<h2>Hallo Leute,</h2>" );
You can’t perform that action at this time.
0 commit comments