Skip to content

Commit

Permalink
Fix issue apache#32252: solved the issue for switching preview and ed…
Browse files Browse the repository at this point in the history
…it mode on click
  • Loading branch information
notHuman9504 committed Feb 20, 2025
1 parent f9a4392 commit 5c53b6b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const StyledContent = styled.div<{
const DashboardContentWrapper = styled.div`
${({ theme }) => css`
&.dashboard {
padding-top: 30px;
position: relative;
flex-grow: 1;
display: flex;
Expand Down Expand Up @@ -651,6 +652,7 @@ const DashboardBuilder = () => {
{renderDraggableContent}
</Droppable>
</StyledHeader>

<StyledContent fullSizeChartId={fullSizeChartId}>
{!editMode &&
!topLevelTabs &&
Expand Down Expand Up @@ -715,6 +717,7 @@ const DashboardBuilder = () => {
</StyledDashboardContent>
</DashboardContentWrapper>
</StyledContent>

{dashboardIsSaving && (
<Loading
css={css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Markdown extends PureComponent {
markdownSource: props.component.meta.code,
editor: null,
editorMode: 'preview',
isEditing: false,
undoLength: props.undoLength,
redoLength: props.redoLength,
};
Expand Down Expand Up @@ -215,17 +216,32 @@ class Markdown extends PureComponent {
}

handleChangeFocus(nextFocus) {
if(this.state.isEditing){
const nextFocused = !!nextFocus;
const nextEditMode = nextFocused ? 'edit' : 'preview';
this.setState(() => ({ isFocused: nextFocused }));
this.handleChangeEditorMode(nextEditMode);
this.handleChangeEditorMode(nextEditMode);}
}

handleChangeEditorMode(mode) {
const nextState = {
let nextState = {
...this.state,
editorMode: mode,
isEditing: mode === 'edit',
};

if(mode == 'edit') {
nextState = {
...this.state,
editorMode: 'edit',
isEditing: true,
};
console.log('here');
}

console.log('is editing', mode == 'edit');
console.log('editor mode', mode);

if (mode === 'preview') {
this.updateMarkdownContent();
nextState.hasError = false;
Expand Down Expand Up @@ -308,7 +324,7 @@ class Markdown extends PureComponent {
}

render() {
const { isFocused, editorMode } = this.state;
const { isFocused, editorMode, isEditing } = this.state;

const {
component,
Expand All @@ -329,8 +345,6 @@ class Markdown extends PureComponent {
? parentComponent.meta.width || GRID_MIN_COLUMN_COUNT
: component.meta.width || GRID_MIN_COLUMN_COUNT;

const isEditing = editorMode === 'edit';

return (
<Draggable
component={component}
Expand Down Expand Up @@ -382,6 +396,17 @@ class Markdown extends PureComponent {
ref={dragSourceRef}
className="dashboard-component dashboard-component-chart-holder"
data-test="dashboard-component-chart-holder"
onClick={() => {
// Only trigger edit mode if we're in editMode but not yet editing


console.log('clicky');
if (editMode && !isEditing) {
console.log('clicked got performed');
this.handleChangeFocus(true);
// this.handleChangeEditorMode('edit');
}
}}
>
{editMode && (
<HoverMenu position="top">
Expand All @@ -390,7 +415,8 @@ class Markdown extends PureComponent {
/>
</HoverMenu>
)}
{editMode && isEditing
{/* {this.renderPreviewMode()} */}
{isEditing
? this.renderEditMode()
: this.renderPreviewMode()}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const PopoverMenuStyles = styled.div`
)};
font-size: ${theme.typography.sizes.m}px;
cursor: default;
z-index: 3000;
z-index: 100000;
&,
.menu-item {
Expand Down

0 comments on commit 5c53b6b

Please sign in to comment.