@@ -132,6 +132,50 @@ describe('Text Inline Popup plugin', () => {
132132 } ) ;
133133 } ) ;
134134
135+ describe ( 'Nested popup position with allowTabNavigation' , ( ) => {
136+ // https://github.com/jodit/jodit-react/issues/290
137+ [ true , false ] . forEach ( allowTabNavigation => {
138+ it ( `Should open near its trigger button when allowTabNavigation=${ allowTabNavigation } ` , ( ) => {
139+ const editor = getJodit ( { allowTabNavigation } ) ;
140+
141+ editor . value =
142+ '<table><tbody><tr><td>cell</td></tr></tbody></table>' ;
143+
144+ const td = editor . editor . querySelector ( 'td' ) ;
145+ const pos = Jodit . modules . Helpers . position ( td ) ;
146+
147+ simulateEvent ( [ 'mousedown' , 'mouseup' , 'click' ] , 0 , td , e => {
148+ Object . assign ( e , {
149+ clientX : pos . left ,
150+ clientY : pos . top
151+ } ) ;
152+ } ) ;
153+
154+ const popup = getOpenedPopup ( editor ) ;
155+ expect ( popup ) . is . not . null ;
156+
157+ const trigger = getButton ( 'brushCell' , popup ) ;
158+ expect ( trigger ) . is . not . null ;
159+
160+ simulateEvent ( 'click' , trigger ) ;
161+
162+ const nested = getOpenedPopup ( editor ) ;
163+ expect ( nested ) . is . not . null ;
164+ expect ( nested ) . does . not . equal ( popup ) ;
165+
166+ const btnRect = trigger . getBoundingClientRect ( ) ;
167+ const popRect = nested . getBoundingClientRect ( ) ;
168+
169+ const distance = Math . min (
170+ Math . abs ( popRect . top - btnRect . bottom ) ,
171+ Math . abs ( popRect . bottom - btnRect . top )
172+ ) ;
173+
174+ expect ( distance ) . is . below ( 50 ) ;
175+ } ) ;
176+ } ) ;
177+ } ) ;
178+
135179 describe ( 'Table' , ( ) => {
136180 describe ( 'Table button' , ( ) => {
137181 describe ( 'Select table cell' , ( ) => {
0 commit comments