mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1456849 - Part 1: Re-arrange the tool tabs if the visibility of command tools are changed. r=jdescottes
MozReview-Commit-ID: EzUfqRUdK6I --HG-- extra : rebase_source : c108f7f183c8030d1ef44fa385e415b0209c22ad
This commit is contained in:
parent
b52948e2af
commit
bd4daf957a
@ -22,6 +22,7 @@ class ToolboxController extends Component {
|
||||
this.state = {
|
||||
focusedButton: ELEMENT_PICKER_ID,
|
||||
toolboxButtons: [],
|
||||
visibleToolboxButtonCount: 0,
|
||||
currentToolId: null,
|
||||
highlightedTools: new Set(),
|
||||
panelDefinitions: [],
|
||||
@ -172,7 +173,10 @@ class ToolboxController extends Component {
|
||||
button.on("updatechecked", this.state.checkedButtonsUpdated);
|
||||
});
|
||||
|
||||
this.setState({ toolboxButtons }, this.updateButtonIds);
|
||||
const visibleToolboxButtonCount =
|
||||
toolboxButtons.filter(button => button.isVisible).length;
|
||||
|
||||
this.setState({ toolboxButtons, visibleToolboxButtonCount }, this.updateButtonIds);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -28,6 +28,7 @@ class ToolboxTabs extends Component {
|
||||
panelDefinitions: PropTypes.array,
|
||||
selectTool: PropTypes.func,
|
||||
toolbox: PropTypes.object,
|
||||
visibleToolboxButtonCount: PropTypes.number.isRequired,
|
||||
L10N: PropTypes.object,
|
||||
onTabsOrderUpdated: PropTypes.func.isRequired,
|
||||
};
|
||||
@ -94,7 +95,8 @@ class ToolboxTabs extends Component {
|
||||
* Return true if we should update the overflowed tabs.
|
||||
*/
|
||||
shouldUpdateToolboxTabs(prevProps, nextProps) {
|
||||
if (prevProps.currentToolId !== nextProps.currentToolId) {
|
||||
if (prevProps.currentToolId !== nextProps.currentToolId ||
|
||||
prevProps.visibleToolboxButtonCount !== nextProps.visibleToolboxButtonCount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,11 @@ class ToolboxToolbar extends Component {
|
||||
toolbox: PropTypes.object,
|
||||
// Call back function to detect tabs order updated.
|
||||
onTabsOrderUpdated: PropTypes.func.isRequired,
|
||||
// Count of visible toolbox buttons which is used by ToolboxTabs component to
|
||||
// recognize that the visibility of toolbox buttons were changed. Because in the
|
||||
// component we cannot compare the visibility since the button definition instance
|
||||
// in toolboxButtons will be unchanged.
|
||||
visibleToolboxButtonCount: PropTypes.number,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user