mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 17:56:01 +03:00
Don't leave button tooltips open when closing modals (#8546)
This commit is contained in:
parent
617c0e3c50
commit
89d7760f36
1 changed files with 8 additions and 2 deletions
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { SyntheticEvent } from 'react';
|
import React, { SyntheticEvent, FocusEvent } from 'react';
|
||||||
|
|
||||||
import AccessibleButton from "./AccessibleButton";
|
import AccessibleButton from "./AccessibleButton";
|
||||||
import Tooltip, { Alignment } from './Tooltip';
|
import Tooltip, { Alignment } from './Tooltip';
|
||||||
|
@ -68,6 +68,12 @@ export default class AccessibleTooltipButton extends React.PureComponent<IProps,
|
||||||
this.props.onHideTooltip?.(ev);
|
this.props.onHideTooltip?.(ev);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onFocus = (ev: FocusEvent) => {
|
||||||
|
// We only show the tooltip if focus arrived here from some other
|
||||||
|
// element, to avoid leaving tooltips hanging around when a modal closes
|
||||||
|
if (ev.relatedTarget) this.showTooltip();
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const { title, tooltip, children, tooltipClassName, forceHide, yOffset, alignment, onHideTooltip,
|
const { title, tooltip, children, tooltipClassName, forceHide, yOffset, alignment, onHideTooltip,
|
||||||
|
@ -84,7 +90,7 @@ export default class AccessibleTooltipButton extends React.PureComponent<IProps,
|
||||||
{...props}
|
{...props}
|
||||||
onMouseOver={this.showTooltip}
|
onMouseOver={this.showTooltip}
|
||||||
onMouseLeave={this.hideTooltip}
|
onMouseLeave={this.hideTooltip}
|
||||||
onFocus={this.showTooltip}
|
onFocus={this.onFocus}
|
||||||
onBlur={this.hideTooltip}
|
onBlur={this.hideTooltip}
|
||||||
aria-label={title}
|
aria-label={title}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue