Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/drafts/MarkdownEditor/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ const MarkdownEditor = forwardRef<MarkdownEditorHandle, MarkdownEditorProps>(
'&: focus-within':
view === 'edit'
? {
outline: '2px solid var(--borderColor-accent-emphasis)',
outline: '2px solid',
outlineColor: 'accent.emphasis',
}
: {},
Comment on lines 403 to 409
Copy link
Contributor

@iansan5653 iansan5653 Nov 6, 2023

Choose a reason for hiding this comment

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

I think this is non-blocking since it feels like something we can tweak later, but the PVC component only shows focus on the whole editor when the textarea is focused. When focus is on the toolbar, the blue outline around the editor is not rendered. For example:

Screenshot of PVC commentbox with focus on a toolbar button. One blue outline is visible around that button.

The same is not true for this component, where we show the outline whenever focus is anywhere inside the editor:

Screenshot of React commentbox with focus on a toolbar button. Two blue outlines are visible: one around the button and one around the entire commentbox region.

The problem is how we would do this: has would be the perfect solution here (&:has(textarea:focus), but browser support is not there (thanks Firefox). Maybe it's worth waiting for browser support rather than rolling some custom React state-based solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we capture this in a new issue? It seems like Firefox will support :has by Christmas: https://groups.google.com/a/mozilla.org/g/dev-platform/c/oacuvZ2_hLg/m/4o28pFLkAwAJ?pli=1 🎉

Copy link
Member

Choose a reason for hiding this comment

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

Oh that's interesting. We already use :has in primer/react in a few places. I'm assuming this is because dotcom uses a polyfill

...sx,
Expand All @@ -424,13 +425,29 @@ const MarkdownEditor = forwardRef<MarkdownEditorHandle, MarkdownEditorProps>(
}}
as="header"
>
<Box sx={{ml: '-1px', mt: '-1px', display: 'flex', alignItems: 'flex-end'}}>
<Box
sx={{
ml: '-1px',
mt: '-1px',
display: 'flex',
alignItems: 'flex-end',
flexGrow: 1,
flexBasis: 0,
}}
>
<ViewSwitch
selectedView={view}
onViewSelect={setView}
disabled={fileHandler?.uploadProgress !== undefined}
onLoadPreview={loadPreview}
/>
<Box
sx={{
borderBottom: '1px solid',
borderBottomColor: 'border.subtle',
flexGrow: 1,
}}
/>
</Box>

<SavedRepliesContext.Provider value={savedRepliesContext}>
Expand Down