Skip to content

Commit 417bf01

Browse files
committed
remove workaround for fixed-in-2017 Safari bug, especially because it triggered deprecated react warnings
1 parent c83f09b commit 417bf01

File tree

7 files changed

+3
-55
lines changed

7 files changed

+3
-55
lines changed

src/packages/frontend/editor.coffee

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,13 +1375,6 @@ class CodeMirrorEditor extends FileEditor
13751375
# Save for next time
13761376
@_last_layout = @_layout
13771377

1378-
# Workaround a major and annoying bug in Safari:
1379-
# https://github.com/philipwalton/flexbugs/issues/132
1380-
if $.browser.safari and @_layout == 1
1381-
# This is only needed for the "split via a horizontal line" layout, since
1382-
# the flex layout with column direction is broken on Safari.
1383-
@element.find(".webapp-editor-codemirror-input-container-layout-#{@_layout}").make_height_defined()
1384-
13851378
refresh = (cm) =>
13861379
return if not cm?
13871380
cm_refresh(cm)

src/packages/frontend/frame-editors/code-editor/codemirror-editor.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,20 +215,12 @@ export const CodemirrorEditor: React.FC<Props> = React.memo((props) => {
215215
editor_actions()?.syncstring_commit();
216216
}
217217

218-
function safari_hack(): void {
219-
if (is_safari()) {
220-
$(ReactDOM.findDOMNode(divRef.current)).make_height_defined();
221-
}
222-
}
223-
224218
async function init_codemirror(props: Props): Promise<void> {
225219
const node: HTMLTextAreaElement = ReactDOM.findDOMNode(textareaRef.current);
226220
if (node == null) {
227221
return;
228222
}
229223

230-
safari_hack();
231-
232224
const options: any = cm_options(
233225
props.path,
234226
props.editor_settings,
@@ -309,7 +301,7 @@ export const CodemirrorEditor: React.FC<Props> = React.memo((props) => {
309301
(cm as any)._actions = editor_actions();
310302

311303
if (props.is_public) {
312-
if (props.value !== undefined) {
304+
if (props.value != null) {
313305
// should always be the case if public.
314306
cm.setValue(props.value);
315307
}
@@ -514,8 +506,6 @@ export const CodemirrorEditor: React.FC<Props> = React.memo((props) => {
514506
);
515507
});
516508

517-
CodemirrorEditor.defaultProps = { value: "" };
518-
519509
// Needed e.g., for vim ":w" support; this is global,
520510
// so be careful.
521511
if ((CodeMirror as any).commands.save == null) {

src/packages/frontend/frame-editors/frame-tree/frame-tree-drag-bar.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ interface Props {
5858
// the direction
5959
dir: "col" | "row";
6060
frame_tree: Map<string, any>;
61-
safari_hack: () => void;
6261
}
6362

6463
export const FrameTreeDragBar: React.FC<Props> = React.memo((props: Props) => {
65-
const { dir, frame_tree, actions, safari_hack, containerRef } = props;
64+
const { dir, frame_tree, actions, containerRef } = props;
6665

6766
const dragBarRef = React.useRef<Draggable>(null);
6867

@@ -104,7 +103,6 @@ export const FrameTreeDragBar: React.FC<Props> = React.memo((props: Props) => {
104103
setDragActive(false);
105104
drag_stop_iframe_enable();
106105
calcPosition(_, ui);
107-
safari_hack();
108106
}
109107

110108
function style(): CSS | undefined {

src/packages/frontend/frame-editors/frame-tree/frame-tree.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ export const FrameTree: React.FC<FrameTreeProps> = React.memo(
461461
containerRef={cols_container_ref}
462462
dir={"col"}
463463
frame_tree={frame_tree}
464-
safari_hack={safari_hack}
465464
/>
466465
<div className={"smc-vfill"} style={data.style_second}>
467466
{render_one(data.second)}
@@ -470,17 +469,6 @@ export const FrameTree: React.FC<FrameTreeProps> = React.memo(
470469
);
471470
}
472471

473-
function safari_hack() {
474-
if (!is_safari()) {
475-
return;
476-
}
477-
// Workaround a major and annoying bug in Safari:
478-
// https://github.com/philipwalton/flexbugs/issues/132
479-
return $(ReactDOM.findDOMNode(elementRef.current))
480-
.find(".cocalc-editor-div")
481-
.make_height_defined();
482-
}
483-
484472
function render_rows() {
485473
const data = get_data("column");
486474
return (
@@ -497,7 +485,6 @@ export const FrameTree: React.FC<FrameTreeProps> = React.memo(
497485
containerRef={rows_container_ref}
498486
dir={"row"}
499487
frame_tree={frame_tree}
500-
safari_hack={safari_hack}
501488
/>
502489
<div className={"smc-vfill"} style={data.style_second}>
503490
{render_one(data.second)}

src/packages/frontend/frame-editors/generic/jquery-plugins.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@
66
import "jquery";
77

88
declare global {
9-
interface JQuery {
10-
make_height_defined(): JQuery;
11-
}
9+
interface JQuery {}
1210
}

src/packages/frontend/frame-editors/html-editor/iframe-html.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export const IFrameHTML: React.FC<Props> = React.memo((props: Props) => {
8585
React.useEffect(function () {
8686
mounted.current = true;
8787
reload_iframe();
88-
safari_hack();
8988
set_iframe_style(scaling);
9089
return function () {
9190
mounted.current = false;
@@ -206,12 +205,6 @@ export const IFrameHTML: React.FC<Props> = React.memo((props: Props) => {
206205
}
207206
}
208207

209-
function safari_hack(): void {
210-
if (is_safari()) {
211-
$(ReactDOM.findDOMNode(rootEl.current)).make_height_defined();
212-
}
213-
}
214-
215208
function render_no_html(): Rendered {
216209
return (
217210
<div>

src/packages/frontend/jquery-plugins/height.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,3 @@ $.fn.maxheight = function (opts: { offset?: number } = {}) {
1616
});
1717
return this;
1818
};
19-
20-
// Use to workaround Safari flex layout bug https://github.com/philipwalton/flexbugs/issues/132
21-
$.fn.make_height_defined = function () {
22-
this.each(function () {
23-
// @ts-ignore
24-
const elt = $(this);
25-
// Doing this makes the height **defined**, so that flexbox can use it even on safari.
26-
elt.height(elt.height());
27-
});
28-
return this;
29-
};

0 commit comments

Comments
 (0)