Skip to content

Commit 3ab20be

Browse files
committed
feat: add useRef for nodeRef in SortableTableHeaderCell component
1 parent 5726353 commit 3ab20be

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.22.8-beta-15",
3+
"version": "1.22.8-beta-16",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/SortableTableHeaderCell/SortableTableHeaderCell.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { useRef } from 'react'
1718
import Draggable, { DraggableProps } from 'react-draggable'
1819

1920
import { ReactComponent as SortIcon } from '@Icons/ic-arrow-up-down.svg'
@@ -69,6 +70,7 @@ const SortableTableHeaderCell = ({
6970
handleResize,
7071
isResizable,
7172
}: SortableTableHeaderCellProps) => {
73+
const nodeRef = useRef<HTMLDivElement>(null)
7274
const isCellResizable = !!(isResizable && id && handleResize)
7375

7476
const renderSortIcon = () => {
@@ -113,6 +115,7 @@ const SortableTableHeaderCell = ({
113115
</button>
114116
{isCellResizable && (
115117
<Draggable
118+
nodeRef={nodeRef}
116119
handle=".sortable-table-header__resize-btn"
117120
defaultClassNameDragging="sortable-table-header__resize-btn--dragging"
118121
position={{
@@ -126,7 +129,10 @@ const SortableTableHeaderCell = ({
126129
bottom: 0,
127130
}}
128131
>
129-
<div className="sortable-table-header__resize-btn flex h-100 dc__no-shrink px-2 dc__position-abs dc__cursor-col-resize dc__right-3--neg">
132+
<div
133+
ref={nodeRef}
134+
className="sortable-table-header__resize-btn flex h-100 dc__no-shrink px-2 dc__position-abs dc__cursor-col-resize dc__right-3--neg"
135+
>
130136
<div className="dc__divider h-16" />
131137
</div>
132138
</Draggable>

0 commit comments

Comments
 (0)