@bpmn-io/properties-panel 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -393,7 +393,16 @@ function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky)
393
393
  let observer;
394
394
  if (ref.current) {
395
395
  const scrollContainer = query(scrollContainerSelector);
396
+
397
+ // TODO(@barmac): test this
398
+ if (!scrollContainer) {
399
+ return;
400
+ }
396
401
  observer = new Observer(entries => {
402
+ // The ScrollContainer is unmounted, do not update sticky state
403
+ if (scrollContainer.scrollHeight === 0) {
404
+ return;
405
+ }
397
406
  entries.forEach(entry => {
398
407
  if (entry.intersectionRatio < 1) {
399
408
  setSticky(true);
@@ -416,7 +425,7 @@ function useStickyIntersectionObserver(ref, scrollContainerSelector, setSticky)
416
425
  observer.unobserve(ref.current);
417
426
  }
418
427
  };
419
- }, [ref, scrollContainerSelector, setSticky]);
428
+ }, [ref.current, scrollContainerSelector, setSticky]);
420
429
  }
421
430
 
422
431
  /**
@@ -640,7 +649,7 @@ function PropertiesPanel(props) {
640
649
  const [layout, setLayout] = useState(createLayout(layoutConfig));
641
650
 
642
651
  // react to external changes in the layout config
643
- useUpdateEffect(() => {
652
+ useUpdateLayoutEffect(() => {
644
653
  const newLayout = createLayout(layoutConfig);
645
654
  setLayout(newLayout);
646
655
  }, [layoutConfig]);
@@ -761,14 +770,14 @@ function createDescriptionContext(overrides = {}) {
761
770
  // hooks //////////////////
762
771
 
763
772
  /**
764
- * This hook behaves like useEffect, but does not trigger on the first render.
773
+ * This hook behaves like useLayoutEffect, but does not trigger on the first render.
765
774
  *
766
775
  * @param {Function} effect
767
776
  * @param {Array} deps
768
777
  */
769
- function useUpdateEffect(effect, deps) {
778
+ function useUpdateLayoutEffect(effect, deps) {
770
779
  const isMounted = useRef(false);
771
- useEffect(() => {
780
+ useLayoutEffect(() => {
772
781
  if (isMounted.current) {
773
782
  return effect();
774
783
  } else {