Switch AccessibleButton and derivatives to using forwardRef#12054
Switch AccessibleButton and derivatives to using forwardRef#12054
forwardRef#12054Conversation
This prevented us from switching to `forwardRef` in a bunch of places due to it behaving different with & without strict mode. Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
ffe6edd to
0515c40
Compare
richvdh
left a comment
There was a problem hiding this comment.
there's a lot changing here - much of which, at first glance, doesn't appear to match the PR description (ie, it is not about using forwardRef).
Could you either break up the PR, or help me as a reviewer understand what I'm looking at by making a clear description of it?
This is a broken up PR, this is as small as it can get, given how many places use & extend
Just updated branch which knocked out some bits unrelated to |
Well, you seem to have found a way to make it smaller since I first looked at it, so thank you for that. |
|
@richvdh yeah its an unfortunate side effect of squash merging combined with PR stacking =( |
richvdh
left a comment
There was a problem hiding this comment.
Looks generally plausible, but I have some requests mostly around better documentation.
src/components/views/rooms/wysiwyg_composer/components/WysiwygAutocomplete.tsx
Outdated
Show resolved
Hide resolved
src/components/views/rooms/wysiwyg_composer/components/WysiwygAutocomplete.tsx
Show resolved
Hide resolved
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
… t3chguy/cr/157-2 # Conflicts: # src/components/structures/InteractiveAuth.tsx # src/components/views/auth/InteractiveAuthEntryComponents.tsx # src/components/views/dialogs/DeactivateAccountDialog.tsx # src/components/views/dialogs/InteractiveAuthDialog.tsx # src/components/views/elements/AccessibleButton.tsx # src/components/views/elements/AccessibleTooltipButton.tsx # src/components/views/messages/CallEvent.tsx # src/components/views/rooms/ReadReceiptMarker.tsx
|
Another split out #12075 |
… t3chguy/cr/157-2 Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> # Conflicts: # src/accessibility/context_menu/ContextMenuButton.tsx # src/accessibility/context_menu/ContextMenuTooltipButton.tsx # src/components/views/audio_messages/PlayPauseButton.tsx # src/components/views/elements/AccessibleButton.tsx # src/components/views/elements/AccessibleTooltipButton.tsx # src/components/views/elements/LearnMore.tsx
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
| * as a button. Identifies the element as a button, setting proper tab | ||
| * indexing and keyboard activation behavior. | ||
| * | ||
| * If a ref is passed, it will be forwarded to the rendered element as specified using the `element` prop. |
There was a problem hiding this comment.
| * If a ref is passed, it will be forwarded to the rendered element as specified using the `element` prop. | |
| * If a ref is provided, it will be forwarded to the rendered element (as specified using the `element` prop). | |
| * If `element` is a DOM element, the ref will be updated to point to the rendered DOM node. |
There was a problem hiding this comment.
If
elementis a DOM element, the ref will be updated to point to the rendered DOM node.
element can only be a string though, not a DOM element. It can be a name of a DOM element but it also can't be anything else (other than undefined where the value is div) so not sure what this 2nd line is trying to say.
There was a problem hiding this comment.
My understanding is that element can either be an intrinsic DOM element (div, button, or whatever), or a React component (MyFancyButton). (See https://www.typescriptlang.org/docs/handbook/jsx.html#type-checking, etc)
- If it's a react component, we can't really say much about what happens to the ref other than that it is forwarded to that component for it to do with as it chooses. (It might set it to 42, for all we know.)
- However, if it's an intrinsic DOM element, then we can be much more helpful: the act of "forwarding" it means that
ref.contentwill be updated to point to the rendered DOM node corresponding to that element. This is what the user ofAccessibleButtonneeds to know, and is the reason that I wanted to add that second sentence.
Now: if you're saying that element can't in fact be a React component and can only ever be an intrinsic DOM element, then we can clarify this further (since "forwarding" is entirely an implementation detail of AccessibleButton). Maybe something like:
| * If a ref is passed, it will be forwarded to the rendered element as specified using the `element` prop. | |
| * If a ref is provided, it will be updated to point to the rendered DOM node (which will normally be a `div`, | |
| * unless overridden via the `element` property). |
There was a problem hiding this comment.
yup I misread the typescript. (#include "I shouldn't have to reverse-engineer typescript types.rant")


For https://github.com/element-hq/customer-retainer/issues/157
Requires #12053
This is to enable AccessibleTooltipButton using Compound's Tooltip which requires this.
This change is marked as an internal change (Task), so will not be included in the changelog.