Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
fixed isResizeHandleActive not resetting
Browse files Browse the repository at this point in the history
  • Loading branch information
sdadn committed Oct 18, 2023
1 parent 6e66593 commit 74fb315
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,8 @@ const ColumnHeaderCell = (props) => {
const [isResizeHandleActive, setResizeHandleActive] = useState(false);

useEffect(() => {
if (isActive) {
if (isResizeActive) {
if (isActive && isResizeActive) {
setResizeHandleActive(true);
}
} else {
setResizeHandleActive(false);
}
Expand Down Expand Up @@ -206,7 +204,6 @@ const ColumnHeaderCell = (props) => {
if (isResizable && isResizeHandleActive) {
columnHeaderCellRef.current.focus();
setResizeHandleActive(false);

event.stopPropagation();
event.preventDefault();
}
Expand Down Expand Up @@ -273,6 +270,7 @@ const ColumnHeaderCell = (props) => {
columnWidth={width}
columnResizeIncrement={columnResizeIncrement}
isActive={isResizeHandleActive}
setIsActive={setResizeHandleActive}
height={tableHeight}
minimumWidth={minimumWidth}
maximumWidth={maximumWidth}
Expand Down
21 changes: 17 additions & 4 deletions packages/terra-data-grid/src/subcomponents/ColumnResizeHandle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const propTypes = {
* Control is the active element
*/
isActive: PropTypes.bool,
/**
* Callback to update isActive for parent.
*/
setIsActive: PropTypes.func,
/**
* Number that specifies the minimum column width in pixels.
*/
Expand All @@ -57,6 +61,12 @@ const propTypes = {
* Function that is called when the the keyboard is used to adjust the column size.
*/
onResizeHandleChange: PropTypes.func,

/**
* Function that is called when the the keyboard is used to adjust the column size.
*/
onResizeHandleBlur: PropTypes.func,

/**
* @private
* The intl object containing translations. This is retrieved from the context automatically by injectIntl.
Expand All @@ -71,17 +81,19 @@ const defaultProps = {
const ColumnResizeHandle = (props) => {
const {
columnIndex,
columnResizeIncrement,
columnText,
columnWidth,
height,
columnResizeIncrement,
intl,
isActive,
minimumWidth,
maximumWidth,
minimumWidth,
onResizeHandleBlur,
onResizeHandleChange,
onResizeMouseDown,
onResizeMouseUp,
onResizeHandleChange,
intl,
setIsActive
} = props;

// Retrieve current theme from context
Expand Down Expand Up @@ -187,6 +199,7 @@ const ColumnResizeHandle = (props) => {
const onBlur = () => {
setNavigationEnabled(true);
setIsAriaLabel(false);
setIsActive(false);
};

return (
Expand Down

0 comments on commit 74fb315

Please sign in to comment.