Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated overflow properties #2688

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove deprecated overflow properties
SylvainCorlay committed Jan 8, 2020
commit e6eceeb2a809a538da15b4fbf99d389ede534908
10 changes: 4 additions & 6 deletions docs/source/examples/Variable Inspector.ipynb
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@
" self.namespace.shell = ipython.kernel.shell\n",
" \n",
" self._box = widgets.Box()\n",
" self._box.layout.overflow_y = 'scroll'\n",
" self._box.layout.overflow = 'visible scroll'\n",
" self._table = widgets.HTML(value = 'Not hooked')\n",
" self._box.children = [self._table]\n",
" \n",
@@ -80,10 +80,8 @@
" '</td></tr><tr><td>'.join(['{0}</td><td>{1}</td><td>{2}'.format(v, type(eval(v)).__name__, str(eval(v))) for v in values]) + \\\n",
" '</td></tr></table></div>'\n",
"\n",
" def _ipython_display_(self):\n",
" \"\"\"Called when display() or pyout is used to display the Variable \n",
" Inspector.\"\"\"\n",
" self._box._ipython_display_()\n"
" def _repr_mimebundle_(self, **kwargs):\n",
" return self._box._repr_mimebundle_(**kwargs)"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to remove the _ipython_display_ call because if was removed from the base Jupyter widget.

]
},
{
@@ -181,7 +179,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.7.3"
}
},
"nbformat": 4,
2 changes: 0 additions & 2 deletions docs/source/examples/Widget Styling.ipynb
Original file line number Diff line number Diff line change
@@ -52,8 +52,6 @@
"- `visibility`\n",
"- `display`\n",
"- `overflow`\n",
"- `overflow_x` (deprecated) \n",
"- `overflow_y` (deprecated)\n",
"\n",
"#### Box model\n",
"\n",
9 changes: 0 additions & 9 deletions ipywidgets/widgets/widget_layout.py
Original file line number Diff line number Diff line change
@@ -54,8 +54,6 @@ class Layout(Widget):
min_height = Unicode(None, allow_none=True, help="The min-height CSS attribute.").tag(sync=True)
min_width = Unicode(None, allow_none=True, help="The min-width CSS attribute.").tag(sync=True)
overflow = Unicode(None, allow_none=True, help="The overflow CSS attribute.").tag(sync=True)
overflow_x = CaselessStrEnum(['visible', 'hidden', 'scroll', 'auto'] + CSS_PROPERTIES, allow_none=True, help="The overflow-x CSS attribute (deprecated).").tag(sync=True)
overflow_y = CaselessStrEnum(['visible', 'hidden', 'scroll', 'auto'] + CSS_PROPERTIES, allow_none=True, help="The overflow-y CSS attribute (deprecated).").tag(sync=True)
order = Unicode(None, allow_none=True, help="The order CSS attribute.").tag(sync=True)
padding = Unicode(None, allow_none=True, help="The padding CSS attribute.").tag(sync=True)
right = Unicode(None, allow_none=True, help="The right CSS attribute.").tag(sync=True)
@@ -77,13 +75,6 @@ class Layout(Widget):
grid_column = Unicode(None, allow_none=True, help="The grid-column CSS attribute.").tag(sync=True)
grid_area = Unicode(None, allow_none=True, help="The grid-area CSS attribute.").tag(sync=True)

@validate('overflow_x', 'overflow_y')
def _validate_overflows(self, proposal):
if proposal.value is not None:
import warnings
warnings.warn("Layout properties overflow_x and overflow_y have been deprecated and will be dropped in a future release. Please use the overflow shorthand property instead", DeprecationWarning)
return proposal.value


class LayoutTraitType(Instance):

36 changes: 0 additions & 36 deletions packages/base/src/widget_layout.ts
Original file line number Diff line number Diff line change
@@ -32,8 +32,6 @@ let css_properties: {[key: string]: string} = {
min_height: null,
min_width: null,
overflow: null,
overflow_x: null, // deprecated
overflow_y: null, // deprecated
order: null,
padding: null,
right: null,
@@ -91,19 +89,6 @@ class LayoutView extends WidgetView {
registerTrait(trait: string) {
this._traitNames.push(trait);

// Treat overflow_x and overflow_y as a special case since they are deprecated
// and interact in special ways with the overflow attribute.
if (trait === 'overflow_x' || trait === 'overflow_y') {
// Listen to changes, and set the value on change.
this.listenTo(this.model, 'change:' + trait, (model: any, value: any) => {
this.handleOverflowChange(trait, value);
});

// Set the initial value on display.
this.handleOverflowChange(trait, this.model.get(trait));
return;
}

// Listen to changes, and set the value on change.
this.listenTo(this.model, 'change:' + trait, (model: LayoutModel, value: any) => {
this.handleChange(trait, value);
@@ -139,27 +124,6 @@ class LayoutView extends WidgetView {
}
}

/**
* Handles when the value of overflow_x or overflow_y changes
*/
handleOverflowChange(trait: string, value: any) {
// This differs from the default handleChange method
// in that setting `overflow_x` or `overflow_y` to null
// when `overflow` is null removes the attribute.
let parent = this.options.parent as DOMWidgetView;
if (parent) {
if (value === null) {
if (this.model.get('overflow') === null) {
parent.el.style.removeProperty(this.css_name(trait));
}
} else {
parent.el.style[this.css_name(trait)] = value;
}
} else {
console.warn('Style not applied because a parent view does not exist');
}
}

/**
* Remove the styling from the parent view.
*/
2 changes: 0 additions & 2 deletions packages/schema/jupyterwidgetmodels.latest.md
Original file line number Diff line number Diff line change
@@ -50,8 +50,6 @@ Attribute | Type | Default | Help
`object_position` | `null` or string | `null` | The object-position CSS attribute.
`order` | `null` or string | `null` | The order CSS attribute.
`overflow` | `null` or string | `null` | The overflow CSS attribute.
`overflow_x` | `null` or string (one of `'visible'`, `'hidden'`, `'scroll'`, `'auto'`, `'inherit'`, `'initial'`, `'unset'`) | `null` | The overflow-x CSS attribute (deprecated).
`overflow_y` | `null` or string (one of `'visible'`, `'hidden'`, `'scroll'`, `'auto'`, `'inherit'`, `'initial'`, `'unset'`) | `null` | The overflow-y CSS attribute (deprecated).
`padding` | `null` or string | `null` | The padding CSS attribute.
`right` | `null` or string | `null` | The right CSS attribute.
`top` | `null` or string | `null` | The top CSS attribute.