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
Removed debug switch, added bug button state update #10727
Conversation
Thanks for making a pull request to JupyterLab! To try out this branch on binder, follow this link: |
I like the conceptual idea that the debugger button is related to the other kernel items. At the same time, I think this control might work better to the left of the kernel switcher UI. Historically, the kernel status indicator has been the right-most toolbar icon, and I think it makes sense to preserve that positioning. @3coins can you try it to the left of the kernel switcher? |
29781b2
to
8c94974
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved from a UX perspective
Done, plz take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this!
- As a partially colorblind person I have to object to the current implementation as it is not accessible. We need a different icon for the active state, distinguished by more than color as proposed in Remove debug buttons in toolbar #10680 (comment). I don't care if it gets the run triangle icon "|>" added, is upside down, rotated or anything else - but it has to differ. Let's not introduce new accessibility issues :). Please let me know iff you need help with creating a new icon.
- Would it be a good idea to make the tooltip ("'Enable / Disable Debugger'") state-specific, this is show either "Enable Debugger" or "Disable Debugger" depending on the state?
- There is also a regression for screen readers (aria state which was conveyed by
Switch
toggle got removed without an alternative added).
588434a
to
2cd5090
Compare
Thanks a lot for this one @3coins I wonder if it could be better to always display the icon (with a status disabled if the kernel does not support debugger). The delay to display the debug icon when switching kernels feels awkward; see animation below. What do you think @ellisonbg ? |
Thanks for that suggestion. I agree that it is clunky the way debug button is added into the page. @ellisonbg, let me know what you think having a disabled button there from UX perspective. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @3coins
I left some comments. Could you also address those two generic points:
- methods should be documented (short sentence on what they are doing and what are their arguments and returned value)
- please type the return value of functions
- please type the private variables
packages/debugger/src/handler.ts
Outdated
const trans = translator.load('jupyterlab'); | ||
const icon = new ToolbarButton({ | ||
className: 'jp-DebuggerBugButton', | ||
icon: bugIcon, | ||
tooltip: trans.__('Enable / Disable Debugger'), | ||
tooltip: trans.__('Enable Debugger'), | ||
ariaLabel: trans.__('Enable/Disable Debugger'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@3coins I will drop the aria-label
as the title has the same content and is changing depending on the button state (on the opposite of the aria-label
)
:root { | ||
--jp-notebook-toolbar-padding: 2px 5px 2px 2px; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -607,10 +625,57 @@ export class ToolbarButton extends ReactWidget { | |||
constructor(private props: ToolbarButtonComponent.IProps = {}) { | |||
super(); | |||
addToolbarButtonClass(this); | |||
this._enabled = props.enabled ?? true; | |||
this._pressed = this._enabled === true ? props.pressed ?? false : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small simplification
this._pressed = this._enabled === true ? props.pressed ?? false : false; | |
this._pressed = this._enabled && props.pressed; |
set pressed(value: boolean) { | ||
if (value != this._pressed) { | ||
this._pressed = value; | ||
this.update(); | ||
} | ||
} | ||
|
||
get pressed() { | ||
return this._enabled === true ? this._pressed : false; | ||
} | ||
|
||
set enabled(value: boolean) { | ||
if (value != this._enabled) { | ||
this._enabled = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should enforce in setter that pressed cannot be set if the button is disabled. So the getter should point to the private value only (otherwise in further use, this._pressed
could be different that this.pressed
).
set pressed(value: boolean) { | |
if (value != this._pressed) { | |
this._pressed = value; | |
this.update(); | |
} | |
} | |
get pressed() { | |
return this._enabled === true ? this._pressed : false; | |
} | |
set enabled(value: boolean) { | |
if (value != this._enabled) { | |
this._enabled = value; | |
set pressed(value: boolean) { | |
if (this.enabled && value !== this._pressed) { | |
this._pressed = value; | |
this.update(); | |
} | |
} | |
get pressed() { | |
return this._pressed; | |
} | |
set enabled(value: boolean) { | |
if (value !== this._enabled) { | |
this._enabled = value; | |
if (!this._enabled) { | |
this._pressed = false; | |
} |
'ui-components:bug-dot' | ||
); | ||
widget.dispose(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test to check that disabled button cannot be pressed.
expect(button.getAttribute('aria-disabled')).toEqual('true'); | ||
widget.dispose(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test that disabling a pressed button, unpressed it.
One additional comment I forgot in the review. The new button should be using the new toolbar customization feature. See for example |
* Removed debug switch * Moved debug button to left of kernel name * Added aria attributes, pressed and enabled states to ToolbarButton component * Disabled debug button when debugging is not supported
2e4282b
to
bbc43fb
Compare
@fcollonval For removing the icon css classes, here is the pull request - #10908 |
Thanks for working on this, it looks great on Binder! Is there any remaining items to fix, or could some of the comments above be addressed in separate PRs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Looks like a follow-up on the UI tests is needed after the merge: https://github.com/jupyterlab/jupyterlab/runs/3482183886 |
Opened #10982 |
This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/how-to-toggle-a-toolbar-button-icon/10952/4 |
This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/how-to-toggle-a-toolbar-button-icon/10952/5 |
Co-authored-by: Piyush Jain <pijain@amazon.com>
This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/jupyterlab-ide-customization/11271/6 |
We may have missed the editor toolbar, as per the report in https://discourse.jupyter.org/t/jupyterlab-ide-customization/11271/5. It indeed does not seem possible to debug standalone scripts anymore in 3.2. CC @3coins. |
Ah good catch, thanks @krassowski. Let's open a new issue to track this? |
References
This PR fixes #10680.
Code changes
User-facing changes
Backwards-incompatible changes
N/A