Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 7943f83

Browse files
authored
Change formatting buttons behavior (#9715)
Change formatting buttons behaviour
1 parent 254815c commit 7943f83

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

res/css/views/rooms/wysiwyg_composer/components/_FormattingButtons.pcss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ limitations under the License.
5353
height: var(--size);
5454
border-radius: 5px;
5555
}
56+
}
5657

58+
.mx_FormattingButtons_Button_hover {
5759
&:hover {
5860
&::after {
5961
background: rgba($secondary-content, 0.1);

src/components/views/rooms/wysiwyg_composer/components/FormattingButtons.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ function Button({ label, keyCombo, onClick, isActive, className }: ButtonProps)
4848
onClick={onClick}
4949
title={label}
5050
className={
51-
classNames('mx_FormattingButtons_Button', className, { 'mx_FormattingButtons_active': isActive })}
51+
classNames('mx_FormattingButtons_Button', className, {
52+
'mx_FormattingButtons_active': isActive,
53+
'mx_FormattingButtons_Button_hover': !isActive,
54+
})}
5255
tooltip={keyCombo && <Tooltip label={label} keyCombo={keyCombo} />}
5356
alignment={Alignment.Top}
5457
/>;

test/components/views/rooms/wysiwyg_composer/components/FormattingButtons-test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,20 @@ describe('FormattingButtons', () => {
7575
// Then
7676
expect(await screen.findByText('Bold')).toBeTruthy();
7777
});
78+
79+
it('Should not have hover style when active', async () => {
80+
// When
81+
const user = userEvent.setup();
82+
render(<FormattingButtons composer={wysiwyg} actionStates={actionStates} />);
83+
await user.hover(screen.getByLabelText('Bold'));
84+
85+
// Then
86+
expect(screen.getByLabelText('Bold')).not.toHaveClass('mx_FormattingButtons_Button_hover');
87+
88+
// When
89+
await user.hover(screen.getByLabelText('Underline'));
90+
91+
// Then
92+
expect(screen.getByLabelText('Underline')).toHaveClass('mx_FormattingButtons_Button_hover');
93+
});
7894
});

0 commit comments

Comments
 (0)