Support dynamically disabling main action button in PopupNotifications
Categories
(Toolkit :: PopupNotifications and Notification Bars, enhancement)
Tracking
()
People
(Reporter: robwu, Unassigned)
References
Details
The popupnotification
element defines the mainactiondisabled
attribute that mirrors to the disabled
property of the primary button (e.g. "Allow" button in permissions prompts). I tried setting this property, but it disappeared because PopupNotifications._setNotificationUIState
toggles the same attribute.
Ideally, PopupNotifications should offer first-class support for toggling the primary's button disabled status. It already has support for disabling a button (by setting mainAction.disabled
), but there is no API to update its flag later.
More details:
PopupNotifications._setNotificationUIState
removes the "mainactiondisabled" attribute by default, because PopupNotifications
supports an optional checkbox
option that is linked to the disabled state of the primary button. The only consumer is WebRTC prompt logic (source), which conditionally sets the checkbox
option. Because the checkbox
option is sometimes present and sometimes absent, PopupNotifications cannot tell for sure whether the button should be disabled, and clears the "mainactiondisabled" just to be safe.
When I added a (XUL) checkbox
that toggles the mainactiondisabled
attribute depending on the checkbox state (in bug 1931548), the main button's disabled state got out of sync. This is because toggling my custom checkbox dispatches a "command" event, that bubbles up and is captured by PopupNotifications._onCommand
, which in turn calls _setNotificationUIState()
that removes the mainactiondisabled
attribute that I had just set. As a work-around for my use case (see patch of bug 1931548), I set the invalidselection
attribute because I noticed that the PopupNotifications._setNotificationUIState
method mirrors that attribute by default, and there is nothing else that sets this attribute in my popupnotification. This feels like a hack though.
Description
•