Add a hint explaining how to leave the editor - #428
fiorsaoirse wants to merge 4 commits into
Conversation
| * If the <Tab> key is enabled as normal input, i.e. it won't have the behavior of changing to the next input element, expected in a web app. | ||
| * @deprecated No longer affects Tab key behavior. Use `tabIntentStyle` and `tabForceSpaceForModes` instead. | ||
| */ | ||
| enableTab?: boolean; |
There was a problem hiding this comment.
This property allowed to override Tab key setting that are set via tabIntentStyle - so it was possible to set tabIntentStyle="space" or set a mode that is listed in tabForceSpaceForModes and set enableTab - so as result we get indention using the Tab key. That's confusing and may lead to unexpected result. I'd suggest deprecating the property and making tabIntentStyle/tabForceSpaceForModes configuration the single source of indention.
There was a problem hiding this comment.
Yes, this is an explicit feature by CodeMirror. Is is possible to set how existing tab characters are displayed but not to support tabbing by itself.
Btw, even if you deprecate a property it need to be work like before until it is removed, otherwise this would be a breaking change. Please also add a version to the deprecation flag, e.g. @deprecated (v27).
| setView(view); | ||
|
|
||
| if (view?.dom) { | ||
| if (height) { |
There was a problem hiding this comment.
Removed the editor's inline height because the container now controls the total height, including the panel (if it exists)
590a165 to
04b5dcb
Compare
8874756 to
0670547
Compare
| */ | ||
| focusHint?: React.ReactElement; | ||
| /** Actions displayed inside the scrollable editing area, to the right of the content. */ | ||
| actions?: React.ReactNode; |
There was a problem hiding this comment.
Looks unrelated to the issue. Maybe done to generalize the way how to add the clear button used in AutoCompleteField. Good idea but this adds more complexity to the change set, should be managed in its own feature branch because the it should be aligned/combined with the existing leftElement/rightElement properties, and maybe moved all together to CodeEditor.
| actions?: React.ReactNode; | ||
| } | ||
|
|
||
| const FALLBACK_WARNING = "Press Escape then Tab to leave the editor."; |
There was a problem hiding this comment.
In my opinion FALLBACK_WARNING is misleading in its intention. Should be something like BLUR_HINT or LEAVE_EDITOR_MSG.
| {hasToolbarSupport && editorToolbar(mode)} | ||
| {shouldIndentWithTab ? ( | ||
| <ApplicationViewability hide="screen"> | ||
| <span lang={focusHint ? undefined : "en"}>{focusHint ?? FOCUS_HINT}</span> |
There was a problem hiding this comment.
This message cannot be focused by Tab because it has no tab index. I think, we can remove this info completely after we decided to display permanently the info in a footer panel how to leave the editor.
| () => | ||
| addExtensionsFor( | ||
| shouldIndentWithTab, | ||
| showPanel.of(createKeyboardHintPanel), |
There was a problem hiding this comment.
Can we have an own class as extension to the default cm-panel class name here?
| <div | ||
| className={`${eccgui}-codeeditor__keyboard-hint`} | ||
| data-testid="code-editor-warning" | ||
| style={{ visibility: focused ? "visible" : "hidden" }} |
There was a problem hiding this comment.
As the footer panel is always visible we probably do not need to hide this message about leaving the editor until the editor is focused.
| }; | ||
|
|
||
| const modeRequiresSpaces = !!(mode && tabForceSpaceForModes?.includes(mode)); | ||
| const shouldIndentWithTab = tabIntentStyle === "tab" && !modeRequiresSpaces; |
There was a problem hiding this comment.
Are you sure on this? Also if spaces are used then tab handling must be activated explicitly. The difference is that spaces used as soft tab, not \t. Using indentWithTab is independent from the actual chars used to display the indentation.
If we really want to remove enableTab then we probably should extend tabIntentStyle by an "off" value.
Currently we have an regression for CodeAutocompleteField because enableTab is ignored now.
PS: the old tabIndent check (you removed it) was probably also wrong regarding the check for tab/space on indentWithTab.
| * If the <Tab> key is enabled as normal input, i.e. it won't have the behavior of changing to the next input element, expected in a web app. | ||
| * @deprecated No longer affects Tab key behavior. Use `tabIntentStyle` and `tabForceSpaceForModes` instead. | ||
| */ | ||
| enableTab?: boolean; |
There was a problem hiding this comment.
Yes, this is an explicit feature by CodeMirror. Is is possible to set how existing tab characters are displayed but not to support tabbing by itself.
Btw, even if you deprecate a property it need to be work like before until it is removed, otherwise this would be a breaking change. Please also add a version to the deprecation flag, e.g. @deprecated (v27).
| gap: $eccgui-size-inline-whitespace; | ||
| align-items: center; | ||
| justify-content: flex-end; | ||
| min-height: $eccgui-size-codeeditor-keyboard-hint-height; |
There was a problem hiding this comment.
We probably do not need to use more space than is needed.
| align-items: center; | ||
| justify-content: flex-end; | ||
| min-height: $eccgui-size-codeeditor-keyboard-hint-height; | ||
| padding: 0.25rem $eccgui-size-inline-whitespace; |
There was a problem hiding this comment.
You can also use 0.5 * $eccgui-size-inline-whitespace to have small widths based on config vars.
| justify-content: flex-end; | ||
| min-height: $eccgui-size-codeeditor-keyboard-hint-height; | ||
| padding: 0.25rem $eccgui-size-inline-whitespace; | ||
| font-size: 0.875rem; |
There was a problem hiding this comment.
Please use scss config vars here, we have font size and lineheight defined also for "caption".
CodeEditorto render actions within the scrollable container (instead of rendering actions as a separated container, seeAutoSuggestioncomponent)Esc + Tabhotkey forAutoSuggestioncomponent