Skip to content

Commit 2b4ce62

Browse files
authored
Fix format bar position (element-hq#28591)
1 parent d68c5a2 commit 2b4ce62

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: src/components/views/rooms/MessageComposerFormatBar.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ interface IState {
3333

3434
export default class MessageComposerFormatBar extends React.PureComponent<IProps, IState> {
3535
private readonly formatBarRef = createRef<HTMLDivElement>();
36+
/**
37+
* The height of the format bar in pixels.
38+
* Height 32px + 2px border
39+
* @private
40+
*/
41+
private readonly BAR_HEIGHT = 34;
3642

3743
public constructor(props: IProps) {
3844
super(props);
@@ -96,7 +102,7 @@ export default class MessageComposerFormatBar extends React.PureComponent<IProps
96102
this.setState({ visible: true });
97103
const parentRect = this.formatBarRef.current.parentElement.getBoundingClientRect();
98104
this.formatBarRef.current.style.left = `${selectionRect.left - parentRect.left}px`;
99-
const halfBarHeight = this.formatBarRef.current.clientHeight / 2; // used to center the bar
105+
const halfBarHeight = this.BAR_HEIGHT / 2; // used to center the bar
100106
const offset = halfBarHeight + 2; // makes sure the bar won't cover selected text
101107
const offsetLimit = halfBarHeight + offset;
102108
const position = Math.max(selectionRect.top - parentRect.top - offsetLimit, -offsetLimit);

0 commit comments

Comments
 (0)