Skip to content

Commit 8f33ebe

Browse files
committed
Prevent copy and select actions when actions are disabled
- should disable copying when submitting is disabled └── packages └── ui └── src └── components └── editor └── common └── prompts ├── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ ├── PromptField.tsx │ ├── hooks │ │ ├── use-drag-drop.ts │ │ ├── use-dropdown.ts │ │ ├── use-ghost-text.ts │ │ ├── use-handlers │ │ │ ├── handle-copy.ts │ │ │ ├── handle-cut.ts │ │ │ ├── handle-input-change.ts │ │ │ ├── handle-input-click.ts │ │ │ ├── handle-key-down.ts │ │ │ ├── handle-paste.ts │ │ │ ├── handle-submit.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ ├── use-handlers.ts │ │ │ └── utils.ts │ │ └── use-keyboard-shortcuts.ts │ └── index.ts ├── Template │ ├── Template.module.scss │ ├── Template.tsx │ └── index.ts └── shared └── symbols ├── caret.ts ├── get-highlighted-text.tsx ├── index.ts ├── position-mapping.ts ├── prompt-symbols.module.scss ├── reconstruct-raw-value.ts └── use-symbol-deletion.ts
1 parent 7991ee2 commit 8f33ebe

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎packages/ui/src/components/editor/common/prompts/PromptField/hooks/use-dropdown.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ export const use_dropdown = (props: PromptFieldProps) => {
3030
}, [])
3131

3232
const handle_copy_click = () => {
33+
if (props.is_action_disabled) return
3334
props.on_copy()
3435
close_dropdown()
3536
}
3637

3738
const handle_select_click = () => {
39+
if (props.is_action_disabled) return
3840
props.on_submit_with_control()
3941
close_dropdown()
4042
}

‎packages/ui/src/components/editor/common/prompts/PromptField/hooks/use-handlers/handle-key-down.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export const create_handle_key_down = (
104104
const selection = window.getSelection()
105105
if (!selection || selection.rangeCount == 0 || selection.isCollapsed) {
106106
e.preventDefault()
107-
props.on_copy()
107+
if (!props.is_action_disabled) {
108+
props.on_copy()
109+
}
108110
return true
109111
}
110112
return false

0 commit comments

Comments
 (0)