@@ -30,6 +30,8 @@ import { actionCreators } from './redux/actions';
3030
3131namespace CssConstants {
3232 export const CellOutputWrapper = 'cell-output-wrapper' ;
33+ export const CellOutputWrapperClass = `.${ CellOutputWrapper } ` ;
34+ export const ImageButtonClass = '.image-button' ;
3335}
3436
3537interface INativeCellBaseProps {
@@ -180,8 +182,8 @@ export class NativeCell extends React.Component<INativeCellProps> {
180182 private onMouseClick = ( ev : React . MouseEvent < HTMLDivElement > ) => {
181183 if ( ev . nativeEvent . target ) {
182184 const elem = ev . nativeEvent . target as HTMLElement ;
183- if ( ! elem . className . includes || ! elem . className . includes ( 'image-button' ) ) {
184- // Not a click on an button in a toolbar, select the cell.
185+ if ( ! elem . closest ( CssConstants . ImageButtonClass ) && ! elem . closest ( CssConstants . CellOutputWrapperClass ) ) {
186+ // Not a click on an button in a toolbar or in output , select the cell.
185187 ev . stopPropagation ( ) ;
186188 this . lastKeyPressed = undefined ;
187189 this . props . selectCell ( this . cellId ) ;
@@ -190,9 +192,12 @@ export class NativeCell extends React.Component<INativeCellProps> {
190192 } ;
191193
192194 private onMouseDoubleClick = ( ev : React . MouseEvent < HTMLDivElement > ) => {
193- // When we receive double click, propagate upwards. Might change our state
194- ev . stopPropagation ( ) ;
195- this . props . focusCell ( this . cellId , CursorPos . Current ) ;
195+ const elem = ev . nativeEvent . target as HTMLElement ;
196+ if ( ! elem . closest ( CssConstants . ImageButtonClass ) && ! elem . closest ( CssConstants . CellOutputWrapperClass ) ) {
197+ // When we receive double click, propagate upwards. Might change our state
198+ ev . stopPropagation ( ) ;
199+ this . props . focusCell ( this . cellId , CursorPos . Current ) ;
200+ }
196201 } ;
197202
198203 private shouldRenderCodeEditor = ( ) : boolean => {
@@ -707,7 +712,7 @@ export class NativeCell extends React.Component<INativeCellProps> {
707712 private focusInOutput ( ) : boolean {
708713 const focusedElement = document . activeElement as HTMLElement ;
709714 if ( focusedElement ) {
710- return focusedElement . closest ( `. ${ CssConstants . CellOutputWrapper } ` ) !== null ;
715+ return focusedElement . closest ( CssConstants . CellOutputWrapperClass ) !== null ;
711716 }
712717 return false ;
713718 }
0 commit comments