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

Fix updating tabs in Calypso broken by new notebook widget #6716

Merged
merged 4 commits into from Jun 28, 2020

Conversation

dionisiydk
Copy link
Contributor

Try to edit setUp method in setUp tab. After accepting changes the browser will show two setUp tabs. That is the bug caused by new notebook (new widget) integration.

In the history I found that #basicUpdateTools was altered to workaround initial tab updating issue: selecting new methods in same class did not update the tab content. This workaround was wrong. At least it should be implemented in explicit place responsible for tab selections (#restoreSelectedTools). But little debugging shows that it was just an issue with new tab implementation (or superclasses which it's based on):

  • tab removal and addition incorrectly update the currently selected tab

Therefore here I provide correct fix and revert Calypso method

ifNotEmpty: [ self selectedIndex: (self selectedIndex - 1) \\ self tabs size + 1 ]
ifEmpty: [ self selectedIndex: 0 ].

super removeTabIndex: anInteger.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

super implementation performs initial selection reset (self selectedIndex: 0).
It is required to trigger updates of selection when tab is removed. Otherwise new selected tab with same index as removed one will not be updated.

self tabs add: (self newLabelMorph: aStringOrMorph) beforeIndex: index.
selectedIndex >= index ifTrue: [
"there is now new tab before selected tab"
self selectedIndex: selectedIndex + 1 ].
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a missing part. If we do not shift selection index then widget will think that selection is not changed and will not update inserted tab in case when it will be seleted in subsequent calls.

@dionisiydk
Copy link
Contributor Author

f459b8e commit fixes #6571

@Ducasse
Copy link
Member

Ducasse commented Jun 28, 2020

Thanks you denis!

@Ducasse
Copy link
Member

Ducasse commented Jun 28, 2020

Having tests is cool. Because this is the only way to control complexity.

@Ducasse Ducasse merged commit 544ffde into pharo-project:Pharo9.0 Jun 28, 2020
@dionisiydk
Copy link
Contributor Author

failed test was really related: #6728.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants