Skip to content

Commit cc68ba3

Browse files
[RTE] Fix for rich text editor toolbar buttons hover state on Android devices (#4748)
1 parent b6c5aa2 commit cc68ba3

6 files changed

Lines changed: 40 additions & 11 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "RTE",
5+
"comment": "Fix for rich text editor toolbar buttons hover state on Android devices",
6+
"packageName": "@azure/communication-react",
7+
"email": "98852890+vhuseinova-msft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "RTE",
5+
"comment": "Fix for rich text editor toolbar buttons hover state on Android devices",
6+
"packageName": "@azure/communication-react",
7+
"email": "98852890+vhuseinova-msft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}

packages/react-components/src/components/styles/RichTextEditor.styles.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,26 @@ const ribbonOverflowButtonRootStyles = (theme: Theme): IStyle => {
124124
};
125125
};
126126

127-
const ribbonButtonRootStyles = (theme: Theme): IStyle => {
127+
const ribbonButtonRootStyles = (iconColor: string, hoverIconColor: string): IStyle => {
128128
return {
129129
backgroundColor: 'transparent',
130130
selectors: {
131-
// Icon's color doesn't work here because of the specificity
131+
// media query applies only if the device allows real hover interactions
132+
// and hover styles are not applied on touch- only devices where the hover state cannot be accurately detected
133+
'@media (hover: hover)': {
134+
':hover .ms-Button-icon': {
135+
color: hoverIconColor
136+
},
137+
':hover .ms-Button-menuIcon': {
138+
color: hoverIconColor
139+
}
140+
},
141+
// the classes needs here to apply to styles for icons because of the specificity
132142
'.ms-Button-icon': {
133-
color: theme.palette.themePrimary
143+
color: iconColor
134144
},
135145
'.ms-Button-menuIcon': {
136-
color: theme.palette.themePrimary
146+
color: iconColor
137147
}
138148
}
139149
};
@@ -147,13 +157,14 @@ export const toolbarButtonStyle = (theme: Theme): Partial<IButtonStyles> => {
147157
icon: { color: theme.palette.neutralPrimary, height: 'auto' },
148158
menuIcon: { color: theme.palette.neutralPrimary, height: 'auto' },
149159
root: { minWidth: 'auto', backgroundColor: 'transparent' },
150-
rootChecked: ribbonButtonRootStyles(theme),
151-
rootHovered: ribbonButtonRootStyles(theme),
152-
rootCheckedHovered: ribbonButtonRootStyles(theme),
153-
rootCheckedPressed: ribbonButtonRootStyles(theme),
154-
rootPressed: ribbonButtonRootStyles(theme),
155-
rootExpanded: ribbonButtonRootStyles(theme),
156-
rootExpandedHovered: ribbonButtonRootStyles(theme)
160+
rootChecked: ribbonButtonRootStyles(theme.palette.themePrimary, theme.palette.themePrimary),
161+
// there is a bug for Android where the press action is considered hover sometimes
162+
rootHovered: ribbonButtonRootStyles(theme.palette.neutralPrimary, theme.palette.themePrimary),
163+
rootCheckedHovered: ribbonButtonRootStyles(theme.palette.themePrimary, theme.palette.themePrimary),
164+
rootCheckedPressed: ribbonButtonRootStyles(theme.palette.themePrimary, theme.palette.themePrimary),
165+
rootPressed: ribbonButtonRootStyles(theme.palette.themePrimary, theme.palette.themePrimary),
166+
rootExpanded: ribbonButtonRootStyles(theme.palette.themePrimary, theme.palette.themePrimary),
167+
rootExpandedHovered: ribbonButtonRootStyles(theme.palette.themePrimary, theme.palette.themePrimary)
157168
};
158169
};
159170

0 commit comments

Comments
 (0)