Skip to content

Commit 8400803

Browse files
committed
Remove redundant arrow-right ghost text handling logic
1 parent 2e2bc18 commit 8400803

3 files changed

Lines changed: 3 additions & 46 deletions

File tree

‎packages/ui/src/components/editor/panel/Fieldset/Fieldset.module.scss‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
cursor: pointer;
1919
}
2020

21-
&__left {
22-
display: flex;
23-
align-items: center;
24-
gap: 4px;
21+
&__text {
22+
transform: translateY(1px);
2523
}
2624
}
2725

‎packages/ui/src/components/editor/panel/Fieldset/Fieldset.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const Fieldset: React.FC<Props> = ({
2525
onClick={on_toggle_collapsed}
2626
role="button"
2727
>
28-
<span>{label}</span>
28+
<span className={styles['fieldset__label__text']}>{label}</span>
2929
<span
3030
className={cn('codicon', {
3131
'codicon-chevron-down': !is_collapsed,

‎packages/ui/src/components/editor/panel/PromptField/hooks/use-handlers.ts‎

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -679,47 +679,6 @@ export const use_handlers = (
679679
const handle_key_down = (e: React.KeyboardEvent<HTMLDivElement>) => {
680680
const { key, shiftKey } = e
681681

682-
// Handle arrow-right when ghost text is present
683-
if (key === 'ArrowRight' && ghost_text && !shiftKey) {
684-
const selection = window.getSelection()
685-
if (
686-
selection &&
687-
selection.rangeCount > 0 &&
688-
selection.isCollapsed &&
689-
input_ref.current
690-
) {
691-
const range = selection.getRangeAt(0)
692-
const ghost_node = input_ref.current.querySelector(
693-
'span[data-type="ghost-text"]'
694-
)
695-
696-
// Check if caret is right before the ghost text node
697-
if (ghost_node) {
698-
const { startContainer, startOffset } = range
699-
700-
let is_before_ghost = false
701-
702-
if (startContainer === ghost_node.previousSibling) {
703-
if (startContainer.nodeType === Node.TEXT_NODE) {
704-
is_before_ghost =
705-
startOffset === startContainer.textContent?.length
706-
}
707-
} else if (startContainer === ghost_node.parentNode) {
708-
const ghost_index = Array.from(startContainer.childNodes).indexOf(
709-
ghost_node as ChildNode
710-
)
711-
is_before_ghost = startOffset === ghost_index
712-
}
713-
714-
if (is_before_ghost) {
715-
e.preventDefault()
716-
on_accept_ghost_text()
717-
return
718-
}
719-
}
720-
}
721-
}
722-
723682
if ((e.ctrlKey || e.metaKey) && !shiftKey && key.toLowerCase() == 'c') {
724683
const selection = window.getSelection()
725684
if (!selection || selection.rangeCount === 0 || selection.isCollapsed) {

0 commit comments

Comments
 (0)