Skip to content

Commit

Permalink
refactor: Fix splitter pop-in for forced sizes (#1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian authored Jun 19, 2024
1 parent ddae31d commit b4977c7
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/components/splitter/index.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useCallback, useEffect, useRef } from 'preact/hooks';
import { useCallback } from 'preact/hooks';
import cx from '../../lib/cx';
import s from './splitter.module.css';

/**
* @param {{orientation: "horizontal" | "vertical", initial?: string, children: any, other: any, force?: boolean}} props
* @param {{orientation: "horizontal" | "vertical", initial?: string, children: any, other: any, force?: string | undefined}} props
*/
export function Splitter({
orientation,
Expand Down Expand Up @@ -46,20 +46,9 @@ export function Splitter({
addEventListener('pointercancel', cancel);
}, []);

const ref = useRef(null);
useEffect(() => {
if (ref.current) {
if (force) {
ref.current.style.setProperty('--size', force);
} else {
ref.current.style.setProperty('--size', initial);
}
}
}, [force]);

return (
<div
ref={ref}
ref={(n) => n?.style.setProperty('--size', force || initial)}
class={cx(
s.container,
orientation === 'horizontal' ? s.horizontal : s.vertical
Expand Down

0 comments on commit b4977c7

Please sign in to comment.