Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 90x 38x 44x 7x 5x 5x 44x 7x 7x 2x | import { LightningElement, api } from 'lwc';
import { findElementByTagNameRecursively } from 'c/privateUtils';
// import AriaObserver from 'lightning/ariaObserver';
export default class EinsteinFeedbackButton extends LightningElement {
// Render component in native shadow mode
static shadowSupportMode = 'native';
_tooltipId = 'tooltip';
_popoverId = 'popover';
_popoverType;
_openPopover = false;
_popoverDisplay;
_tooltipDisplay;
@api ariaLabel;
@api content;
@api placement;
@api symbol;
@api size;
@api selected = 'false';
@api variant;
@api popoverVariant;
@api
get popoverType() {
return this._popoverType;
}
set popoverType(value) {
this._popoverType = value;
}
get popoverDisplay() {
return this.popoverType === 'popover' ? 'display: inline;' : 'display: none;';
}
get tooltipDisplay() {
return this.popoverType === 'tooltip' ? 'display: inline;' : 'display: none;';
}
@api
openPopover() {
this._openPopover = true;
}
// Needed for ariaObserver
// constructor() {
// super();
// this.ariaObserver = new AriaObserver(this);
// }
handlePopoverClose() {
this.dispatchEvent(new CustomEvent('feedbackpopoverclosed'));
this.selected = false;
}
handleTooltipSlotChange(event) {
// Link the <button> and the tooltip's content element through aria-describedby
// so that screenreaders can read out the tooltip content
// Needed for ariaObserver
// const controlRoot = this.template.querySelector('c-button-icon');
// const button = findElementByTagNameRecursively(controlRoot, 'button');
// const tooltipContent = event.target.assignedNodes()[0];
// this.ariaObserver.connect({
// attribute: 'aria-describedby',
// targetNode: button,
// relatedNodes: tooltipContent,
// });
}
/**
* Workaround for component lifecycles and needing elements fully rendered
* to get dimensions to display popovers correctly.
*/
renderedCallback() {
// Needed for ariaObserver
// if (this.isConnected) {
// this.ariaObserver.sync();
// }
if (this.selected && this._openPopover) {
this.template.querySelector('sds-popover-manager').open();
this._openPopover = false;
}
}
}
|