This repository has been archived by the owner on Dec 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Fix #256: Change popup width in overflow menu #271
Merged
biancadanforth
merged 3 commits into
mozilla:master
from
biancadanforth:256-overflow-width
Nov 21, 2018
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
/* global ChromeUtils ExtensionAPI ExtensionCommon */ | ||
/* global ChromeUtils ExtensionAPI */ | ||
|
||
this.customizableUI = class extends ExtensionAPI { | ||
getAPI(context) { | ||
ChromeUtils.import('resource://gre/modules/ExtensionCommon.jsm'); | ||
const {CustomizableUI} = ChromeUtils.import('resource:///modules/CustomizableUI.jsm'); | ||
const {ExtensionCommon} = ChromeUtils.import('resource://gre/modules/ExtensionCommon.jsm'); | ||
const {EventManager} = ExtensionCommon; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not part of this PR, but this seems weirdly formatted compared to the other imports here. |
||
const {CustomizableUI} = ChromeUtils.import('resource:///modules/CustomizableUI.jsm', {}); | ||
const {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm'); | ||
return { | ||
customizableUI: { | ||
onWidgetRemoved: new EventManager( | ||
|
@@ -25,6 +26,15 @@ this.customizableUI = class extends ExtensionAPI { | |
}; | ||
}, | ||
).api(), | ||
async isWidgetInOverflow(widgetId) { | ||
const {area} = CustomizableUI.getPlacementOfWidget(widgetId); | ||
const browserWindow = Services.wm.getMostRecentWindow('navigator:browser'); | ||
// First check is for the non-fixed overflow menu (e.g. widget moved by resizing window) | ||
// Second is for fixed overflow menu (e.g. widget moved by (un)pinning button to overflow) | ||
return ( | ||
CustomizableUI.getWidget(widgetId).forWindow(browserWindow).overflowed | ||
|| area === 'widget-overflow-fixed-list'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This becomes slightly more readable IMO if we format this like this: return (
CustomizableUI.getWidget(widgetId).forWindow(browserWindow).overflowed
|| area === 'widget-overflow-fixed-list'
); |
||
}, | ||
}, | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hmmm, maybe we could put this into one of the React components, like in the state for
BrowserActionApp
? Not sure if that adds much to this.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.
I tried to do this just now, but
<BrowserActionApp />
currently returns a<React.Fragment>
, which doesn't accept a class name. Wrapping the whole thing in a<div>
instead and adding the class to that is possible, but then the CSS also needs another layer instead of applying theoverflow
class directly to#browser-action-app
:Also with the new Study Invitation screen (#274 ), I'd need that wrapper
div
in two places in BrowserActionApp instead of just one.I also tried putting the class name directly on
<BrowserActionApp />
inindex.jsx
, butReactDOM.render
didn't like theawait
keyword needed forbrowser.customizableUI.isWidgetInOverflow
.I think for simplicity, I'll just leave this as is for now. Perhaps we can refactor this later if we ever implement the view router pattern you suggested here... The options I can think of/try right now seem more confusing and more prone to bugs.