Skip to content

Commit 50ae7d5

Browse files
committed
Fix scroll into view not working when revealing method
This fixes a bug where the method row would not scroll into view when revealing a method. The problem was that the `DataGridRow` component on which the `ref` was set is a `display: contents` element, which does not have a visual representation in the DOM. Therefore, it wasn't possible to scroll the method row into view. This fixes it by moving the ref to the `DataGridCell` component of the first column, which is a normal element.
1 parent 135bce8 commit 50ae7d5

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

extensions/ql-vscode/src/view/common/DataGrid.tsx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,28 @@ interface DataGridCellProps {
107107
* cells anywhere within the grid. You can also configure cells to span multiple rows
108108
* or columns. See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column.
109109
*/
110-
export function DataGridCell({
111-
rowType = "default",
112-
gridRow,
113-
gridColumn,
114-
className,
115-
children,
116-
}: DataGridCellProps) {
117-
return (
118-
<StyledDataGridCell
119-
$rowType={rowType}
120-
$gridRow={gridRow}
121-
$gridColumn={gridColumn}
122-
className={className}
123-
>
124-
{children}
125-
</StyledDataGridCell>
126-
);
127-
}
110+
export const DataGridCell = forwardRef(
111+
(
112+
{
113+
rowType = "default",
114+
gridRow,
115+
gridColumn,
116+
className,
117+
children,
118+
}: DataGridCellProps,
119+
ref?: React.Ref<HTMLElement | undefined>,
120+
) => {
121+
return (
122+
<StyledDataGridCell
123+
$rowType={rowType}
124+
$gridRow={gridRow}
125+
$gridColumn={gridColumn}
126+
className={className}
127+
ref={ref}
128+
>
129+
{children}
130+
</StyledDataGridCell>
131+
);
132+
},
133+
);
134+
DataGridCell.displayName = "DataGridCell";

extensions/ql-vscode/src/view/model-editor/MethodRow.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ const ModelableMethodRow = forwardRef<HTMLElement | undefined, MethodRowProps>(
193193
return (
194194
<DataGridRow
195195
data-testid="modelable-method-row"
196-
ref={ref}
197196
focused={revealedMethodSignature === method.signature}
198197
>
199198
<DataGridCell
200199
gridRow={`span ${modeledMethods.length + validationErrors.length}`}
200+
ref={ref}
201201
>
202202
<ApiOrMethodRow>
203203
<ModelingStatusIndicator status={modelingStatus} />
@@ -322,10 +322,9 @@ const UnmodelableMethodRow = forwardRef<
322322
return (
323323
<DataGridRow
324324
data-testid="unmodelable-method-row"
325-
ref={ref}
326325
focused={revealedMethodSignature === method.signature}
327326
>
328-
<DataGridCell>
327+
<DataGridCell ref={ref}>
329328
<ApiOrMethodRow>
330329
<ModelingStatusIndicator status="saved" />
331330
<MethodClassifications method={method} />

0 commit comments

Comments
 (0)