rc-dock icon indicating copy to clipboard operation
rc-dock copied to clipboard

isPopupDiv crashing

Open BartmanAbyss opened this issue 3 years ago • 1 comments

So, this may be totally my fault, I just copied the basic example into my preact-based project, and it always crashes in DockTabs.tsx

function isPopupDiv(r: HTMLDivElement): boolean {
  return (r == null || r.parentElement?.tagName === 'LI' || r.parentElement?.parentElement.tagName === 'LI');
}

callstack shows getHitAreaRef. the last expression fails because r is div.dock-tab-hit-area, r.parentElement is div.drag-initiator, but r.parentElement.parentElement is null.

My temporary fix of adding another ? to the last parentElement worked, and then everything seems to run fine. However I did a git blame on the offending line, and it was last modified 2 years ago, and I assume nobody else ran into this problem, so I'm not sure if I'm to blame ;)

My .tsx

import { DockLayout, LayoutData } from 'rc-dock';
import "rc-dock/dist/rc-dock.css";

const layout: LayoutData = {
	dockbox: {
		mode: 'horizontal',
		children: [
			{
				tabs: [
					{ id: 'tab1', title: 'tab1', content: <div><div>Hello World</div></div> }
				]
			}
		]
	}
};
...

	<DockLayout defaultLayout={layout} style={{position: 'absolute', left: 10, top: 10, right: 10, bottom: 10}}/>

package-lock.json

       "node_modules/preact": "version": "10.10.0",
	"node_modules/rc-dock": "version": "3.2.11",

tsconfig.js

	"compilerOptions": {
...
		"skipLibCheck": true,
		"allowSyntheticDefaultImports": true, // for rc-dock, see https://stackoverflow.com/a/73021533
        "baseUrl": ".",		
        "paths": {
            "react": ["node_modules/preact/compat/"],
            "react-dom": ["node_modules/preact/compat/"]
        }

also, what's up with the compile times? My webpack development build went from 10seconds (before including rc-dock) to 36seconds.

BartmanAbyss avatar Aug 25 '22 21:08 BartmanAbyss

The same issue happens to me.

matej-mnoucek-adsk avatar Nov 04 '22 13:11 matej-mnoucek-adsk