-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[PM-12345] Add cipher type settings for inline autofill menu #11260
Conversation
…ll settings service
…tings view component
…ill settings view component
…ne-menu-positioning-improvements feature flag is off
…ser setting disallows it
New Issues
|
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #11260 +/- ##
=======================================
Coverage 33.16% 33.16%
=======================================
Files 2779 2779
Lines 86228 86291 +63
Branches 16421 16438 +17
=======================================
+ Hits 28597 28619 +22
- Misses 55365 55402 +37
- Partials 2266 2270 +4 ☔ View full report in Codecov by Sentry. |
This comment was marked as resolved.
This comment was marked as resolved.
if (!this.inlineMenuVisibility) { | ||
await this.getInlineMenuVisibility(); | ||
} | ||
|
||
if (this.showInlineMenuCards == null) { | ||
await this.getInlineMenuCardsVisibility(); | ||
} | ||
|
||
if (this.showInlineMenuIdentities == null) { | ||
await this.getInlineMenuIdentitiesVisibility(); | ||
} |
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.
❗ - We have a bit of an issue with how these settings are being referenced/stored.
If we cache these values, and a user changes the setting for showing inline menu cards/identities within their extension, we still retain the presentation of identities/cards on all fields until they refresh the page.
As a result of how we handle binding event listeners on each field, I think we're kind of forced to do a rebuild of the content script logic for each opened tab when the settings change. We do this for changes that happen to the inline menu visibility setting... and likely we need to do the same for these other settings.
Look at the implementation of AutofillService.handleInlineMenuVisibilityChange
to see what we're doing when that setting is modified. Something similar needs to exist for the two now settings... either that, or we need to incorporate some extended logic to unset the listeners of identity or card fields separately (and reset the showAccountCreation
element for login fields)
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.
addressed in 6463191
…isibility setting value changes
tabs.forEach((tab) => | ||
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", { | ||
settingType: cipherType, | ||
newSettingValue, | ||
}), | ||
); |
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.
this.reloadAutofillScripts
call.
Since we're triggering a reload of the content scripts after this, we are in effect trigger a re-init of the entirety of the autofill content script behavior. Updating the setting with a message is a throwaway action as a result of that re-init.
The reason why I originally set up the updateAutofillInlineMenuVisibility
message was to avoid doing this expensive re-load of the scripts. In the current implementation, the inline menu visibility setting is referenced when the menu is opened... the update to that reference should only occur when we need to identify if we want to open the whole menu or just the button on focus.
If the setting is going from and disabled to enabled state (or vice versa), we are forced to trigger a re-injection of the scripts since we load different scripts depending on the visibility setting... otherwise we can just update that content script ref.
Now that said, I think the right call here is to remove the updateAutofillInlineMenuVisibility
message when changing the identity or credit card inline menu settings and just trigger a reload of the script in either regard. The reason we'd want to do that is to ensure we reset the listeners present on all fields. We could implement the reset ourselves in a more optimal manner... but given that these settings aren't likely to be changed often, I think it's fine for us to reload the scripts entirely.
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.
tabs.forEach((tab) => | |
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", { | |
settingType: cipherType, | |
newSettingValue, | |
}), | |
); |
Suggestion, remove this entirely
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.
// If the setting change is for the behavior of overall inline menu display | ||
if (cipherType == null) { | ||
const inlineMenuPreviouslyDisabled = oldSettingValue === AutofillOverlayVisibility.Off; | ||
const inlineMenuCurrentlyDisabled = newSettingValue === AutofillOverlayVisibility.Off; | ||
|
||
if (!inlineMenuPreviouslyDisabled && !inlineMenuCurrentlyDisabled) { | ||
tabs.forEach((tab) => | ||
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", { | ||
newSettingValue, | ||
}), | ||
); | ||
return; | ||
} |
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.
// If the setting change is for the behavior of overall inline menu display | |
if (cipherType == null) { | |
const inlineMenuPreviouslyDisabled = oldSettingValue === AutofillOverlayVisibility.Off; | |
const inlineMenuCurrentlyDisabled = newSettingValue === AutofillOverlayVisibility.Off; | |
if (!inlineMenuPreviouslyDisabled && !inlineMenuCurrentlyDisabled) { | |
tabs.forEach((tab) => | |
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", { | |
newSettingValue, | |
}), | |
); | |
return; | |
} | |
const inlineMenuPreviouslyDisabled = previousSetting === AutofillOverlayVisibility.Off; | |
const inlineMenuCurrentlyDisabled = currentSetting === AutofillOverlayVisibility.Off; | |
if (!inlineMenuPreviouslyDisabled && !inlineMenuCurrentlyDisabled) { | |
const tabs = await BrowserApi.tabsQuery({}); | |
tabs.forEach((tab) => | |
BrowserApi.tabSendMessageData(tab, "updateAutofillInlineMenuVisibility", { | |
inlineMenuVisibility: currentSetting, | |
}), | |
); | |
return; |
Suggestion - revert this logic, only triggering an update when the actual inline menu visibility is modified.
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.
private async handleInlineMenuVisibilitySettingsChange( | ||
oldSettingValue: InlineMenuVisibilitySetting | boolean, | ||
newSettingValue: InlineMenuVisibilitySetting | boolean, | ||
cipherType?: CipherType, |
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.
cipherType?: CipherType, |
Suggestion - Remove this, it likely isn't necessary
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.
this.handleInlineMenuVisibilitySettingsChange( | ||
previousSetting, | ||
currentSetting, | ||
CipherType.Identity, |
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.
CipherType.Identity, |
Suggestion - Remove 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.
this.handleInlineMenuVisibilitySettingsChange( | ||
previousSetting, | ||
currentSetting, | ||
CipherType.Card, |
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.
CipherType.Card, |
Suggestion - Remove 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.
const settingNewValue = data?.newSettingValue; | ||
|
||
if (settingNewValue == null) { | ||
return; | ||
} | ||
|
||
const settingType = data?.settingType; | ||
|
||
// Setting value update is for overall inline menu visibility | ||
if (settingType == null && !isNaN(settingNewValue as InlineMenuVisibilitySetting)) { | ||
this.inlineMenuVisibility = settingNewValue as InlineMenuVisibilitySetting; | ||
|
||
return; | ||
} | ||
|
||
if (typeof settingType === "boolean") { | ||
if (settingType === CipherType.Card) { | ||
this.showInlineMenuCards = settingNewValue as boolean; | ||
} | ||
|
||
if (settingType === CipherType.Identity) { | ||
this.showInlineMenuIdentities = settingNewValue as boolean; | ||
} |
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.
const settingNewValue = data?.newSettingValue; | |
if (settingNewValue == null) { | |
return; | |
} | |
const settingType = data?.settingType; | |
// Setting value update is for overall inline menu visibility | |
if (settingType == null && !isNaN(settingNewValue as InlineMenuVisibilitySetting)) { | |
this.inlineMenuVisibility = settingNewValue as InlineMenuVisibilitySetting; | |
return; | |
} | |
if (typeof settingType === "boolean") { | |
if (settingType === CipherType.Card) { | |
this.showInlineMenuCards = settingNewValue as boolean; | |
} | |
if (settingType === CipherType.Identity) { | |
this.showInlineMenuIdentities = settingNewValue as boolean; | |
} | |
if (!isNaN(data?.inlineMenuVisibility)) { | |
this.inlineMenuVisibility = data.inlineMenuVisibility; |
Suggestion - Revert this, in effect the script reload that is happening when the inline menu cards and inline menu identities setting is changed will handle the expected change to happen on the content script side.
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.
settingType?: CipherType; | ||
newSettingValue?: InlineMenuVisibilitySetting | boolean; |
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.
settingType?: CipherType; | |
newSettingValue?: InlineMenuVisibilitySetting | boolean; | |
inlineMenuVisibility?: InlineMenuVisibilitySetting; |
Suggestion - Revert 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.
🎟️ Tracking
PM-12345
📔 Objective
Provide users a way to turn off the inline autofill menu for specific cipher types
Notes
"inline-menu-positioning-improvements"
feature flag📸 Screenshots
Kapture.2024-09-26.at.15.57.18.mp4
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes