Skip to content

Commit

Permalink
chore: use negative margins on right-justified columns for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
domphan-wandb committed Oct 2, 2024
1 parent dafabc3 commit 2022f09
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions weave-js/src/components/Panel2/PanelTable/ColumnHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ export const ColumnHeader: React.FC<{
};
}, [cellFrame, weave, propsSelectFunction, inputArrayNode]);

const columnNameStyle = columnFormat?.textAlign === 'right'
? {marginLeft: `-${colControlsWidth}px`}
: {marginRight: `-${colControlsWidth}px`};

// When there is a right justified column, reverse the order of the indicators
// and set z-index to 1 otherwise click events on the Ellipses icon is blocked
// by the click event on the column name due to DOM ordering and negative margins.
const columnActionContainerStyle = columnFormat?.textAlign === 'right'
? {zIndex: 1, flexDirection: 'row-reverse'}
: {flexDirection: 'row'};

return (
<S.ColumnHeader
data-test="column-header"
Expand Down Expand Up @@ -543,12 +554,7 @@ export const ColumnHeader: React.FC<{
}}
trigger={
<S.ColumnName
style={{
marginRight:
columnFormat?.textAlign === 'center'
? `-${colControlsWidth}px`
: 'inherit',
}}
style={columnNameStyle}
onClick={() => setColumnSettingsOpen(!columnSettingsOpen)}>
{propsColumnName !== '' ? (
<S.ColumnNameText>{propsColumnName}</S.ColumnNameText>
Expand Down Expand Up @@ -657,10 +663,7 @@ export const ColumnHeader: React.FC<{
{({anchorRef, setOpen, open}) => (
<S.ColumnActionContainer
className="column-controls"
style={{
flexDirection:
columnFormat?.textAlign === 'right' ? 'row-reverse' : 'row',
}}>
style={columnActionContainerStyle}>
<S.ColumnAction>
{isPinned && (
<PinnedIndicator unpin={() => setColumnPinState(false)} />
Expand Down

0 comments on commit 2022f09

Please sign in to comment.