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

Fix CIDER formatting buttons on Safari #5782

Merged
merged 2 commits into from
Mar 22, 2021

Conversation

germain-gg
Copy link
Contributor

Hi folks 👋 ,

This PR fixes element-hq/element-web#15710

The issue stemmed from the fact that document.getSelection() would be empty when called inside BasicMessageComposer.tsx#onFormatAction.
After a bit of digging around it appears that Safari resets the selection if a user clicks on something different than a <button type="button"> (which is odd given that passing the role="button" attribute down should help)

My fix is to essentially use the more semantic HTML tag. I had a bit of CSS tweaking as button inherit a background colour and have a different inline type compared to div.
There are references to an as prop on the AccessibleButton component but could not see it anywhere in the proptypes, I have assumed that element was the appropriate prop to use here

PS: I have updated docs where names have gone stale after migrating from JS to TS

@germain-gg germain-gg added the bug label Mar 22, 2021
@germain-gg germain-gg requested a review from a team March 22, 2021 15:17
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the Safari specific weirdness

LGTM

@jryans jryans changed the title fix: CIDER formatting buttons on Safari Fix CIDER formatting buttons on Safari Mar 22, 2021
@germain-gg germain-gg merged commit c0c8a55 into develop Mar 22, 2021
@germain-gg germain-gg deleted the gsouquet-fix-cider-formatting-safari branch March 22, 2021 15:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CIDER formatting buttons don't work in Safari
2 participants