-
-
Notifications
You must be signed in to change notification settings - Fork 304
Make the rich text editor toolbars a single tab stop with arrow-key navigation #6108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8023f9f
042bd9b
a0b0c66
0b01359
efb2199
ae77d4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in d72a4fb. Class check: grepped every No test: jsdom has no layout or paint order. Verified by reproducing the nesting in a standalone page in headless Chromium — the later option's radio and text sit over the bar before the change and under it after. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| <template> | ||
|
|
||
| <div | ||
| ref="toolbarRef" | ||
| class="floating-panel" | ||
| role="toolbar" | ||
| :aria-label="textFormattingToolbar$()" | ||
|
|
@@ -12,6 +13,7 @@ | |
| > | ||
| <button | ||
| class="toggle-btn" | ||
| data-toolbar-item | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added Audited every |
||
| :title="isExpanded ? collapseFormattingBar$() : expandFormattingBar$()" | ||
| :aria-label="isExpanded ? collapseFormattingBar$() : expandFormattingBar$()" | ||
| :aria-expanded="isExpanded" | ||
|
|
@@ -22,11 +24,14 @@ | |
| {{ isExpanded ? '×' : '+' }} | ||
| </button> | ||
| </div> | ||
| <!-- Chrome gives a scroll container its own tab stop once the roving tabindex | ||
| has left every child at -1. --> | ||
| <div | ||
| v-if="isExpanded" | ||
| id="formatting-tools" | ||
| class="scrollable-tools" | ||
| :aria-label="textFormattingToolbar$()" | ||
| tabindex="-1" | ||
| @touchstart="event => event.stopPropagation()" | ||
| @touchend="event => event.stopPropagation()" | ||
| > | ||
|
|
@@ -36,7 +41,8 @@ | |
| :aria-label="formatSize$()" | ||
| > | ||
| <button | ||
| :disabled="!canDecreaseFormat" | ||
| data-toolbar-item | ||
| :aria-disabled="canDecreaseFormat ? 'false' : 'true'" | ||
| :title="decreaseFormatSize$()" | ||
| :aria-label="decreaseFormatSize$()" | ||
| class="format-btn" | ||
|
|
@@ -51,7 +57,8 @@ | |
| aria-hidden="true" | ||
| > | ||
| <button | ||
| :disabled="!canIncreaseFormat" | ||
| data-toolbar-item | ||
| :aria-disabled="canIncreaseFormat ? 'false' : 'true'" | ||
| :title="increaseFormatSize$()" | ||
| :aria-label="increaseFormatSize$()" | ||
| class="format-btn" | ||
|
|
@@ -122,6 +129,7 @@ | |
| import { useToolbarActions } from '../../composables/useToolbarActions'; | ||
| import { useFormatControls } from '../../composables/useFormatControls'; | ||
| import { getTipTapEditorStrings } from '../../TipTapEditorStrings'; | ||
| import { useRovingTabIndex } from '../../composables/useRovingTabIndex'; | ||
| import ToolbarButton from './ToolbarButton.vue'; | ||
| import ToolbarDivider from './ToolbarDivider.vue'; | ||
|
|
||
|
|
@@ -132,6 +140,9 @@ | |
| const isExpanded = ref(true); | ||
| const keyboardOffset = ref(0); | ||
| const editor = inject('editor'); | ||
| const toolbarRef = ref(null); | ||
|
|
||
| useRovingTabIndex(toolbarRef); | ||
|
Comment on lines
+143
to
+145
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this here? it is inside the mobile toolbar, its not a different toolbar.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
They are further apart now: the bar moved after |
||
|
|
||
| const { | ||
| collapseFormattingBar$, | ||
|
|
@@ -155,13 +166,14 @@ | |
| onMounted(() => { | ||
| if (editor.value) { | ||
| // Use a timeout to allow the keyboard to start appearing | ||
| setTimeout(() => { | ||
| const scrollTimeout = setTimeout(() => { | ||
| const { from } = editor.value.state.selection; | ||
| editor.value.view.dom.querySelector(`[pos="${from}"]`)?.scrollIntoView({ | ||
| behavior: 'smooth', | ||
| block: 'nearest', | ||
| }); | ||
| }, 150); | ||
| onUnmounted(() => clearTimeout(scrollTimeout)); | ||
| } | ||
|
|
||
| const vk = navigator.virtualKeyboard; | ||
|
|
@@ -207,6 +219,7 @@ | |
| return { | ||
| isExpanded, | ||
| keyboardOffset, | ||
| toolbarRef, | ||
| textActions, | ||
| listActions, | ||
| insertTools, | ||
|
|
@@ -306,12 +319,18 @@ | |
| border-radius: 0.25rem; | ||
| } | ||
|
|
||
| .format-btn:disabled { | ||
| .format-btn[aria-disabled='true'] { | ||
| color: #d1d5da; | ||
| cursor: not-allowed; | ||
| border-color: #e1e5e9; | ||
| } | ||
|
|
||
| .toggle-btn:focus-visible, | ||
| .format-btn:focus-visible { | ||
| background: #e6e6e6; | ||
| outline: 2px solid #0097f2; | ||
| } | ||
|
|
||
| .scrollable-tools { | ||
| display: flex; | ||
| flex-grow: 1; | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.