Skip to content

Commit

Permalink
Update suggestions position in Code elements (#483)
Browse files Browse the repository at this point in the history
* draft

* Fix code editor suggestions popover

* Formatting

* Cache monaco options

* Update CHANGELOG.md

---------

Co-authored-by: asimonok <sashasimonok@gmail.com>
Co-authored-by: Mikhail Volkov <mikhail@volkovlabs.io>
  • Loading branch information
3 people authored Sep 6, 2024
1 parent ec48e47 commit e8ab6ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Updated date and time input timezone (#452)
- Added dashboard variables support in button titles (#479)
- Updated suggestions position in Code elements (#483)

## 4.4.0 (2024-08-29)

Expand Down
16 changes: 14 additions & 2 deletions src/components/FormElement/components/CodeElement/CodeElement.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InlineField } from '@grafana/ui';
import { AutosizeCodeEditor } from '@volkovlabs/components';
import React from 'react';
import React, { useMemo } from 'react';

import { FormElementType, TEST_IDS } from '@/constants';
import { CodeLanguage, FormElementByType, LocalFormElement } from '@/types';
Expand All @@ -27,6 +27,18 @@ interface Props {
* Code Element
*/
export const CodeElement: React.FC<Props> = ({ element, onChange }) => {
/**
* Monaco Options
*/
const monacoOptions = useMemo(
() => ({
formatOnPaste: true,
formatOnType: true,
fixedOverflowWidgets: false,
}),
[]
);

return (
<InlineField
label={element.title}
Expand All @@ -52,7 +64,7 @@ export const CodeElement: React.FC<Props> = ({ element, onChange }) => {
}}
modalTitle={`${element.id} editor`}
modalButtonTooltip={`Expand ${element.id}`}
monacoOptions={{ formatOnPaste: true, formatOnType: true }}
monacoOptions={monacoOptions}
aria-label={TEST_IDS.formElements.fieldCode}
readOnly={element.disabled}
/>
Expand Down

0 comments on commit e8ab6ee

Please sign in to comment.