Skip to content

Commit 2c4b6e4

Browse files
wesruvheyMP
andauthored
fix: #1756 #1758 Fix IE11 issues, Safari issues, and Esc key working on compact layout (#1761)
* fix: #1756 #1758 Fix IE11 issues, Safari issues, and Esc key working on compact layout * Removing more code causing errors in IE11 Co-authored-by: heyMP <[email protected]>
1 parent f727065 commit 2c4b6e4

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

CHANGELOG-1.x.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
- [b691da0](https://github.com/patternfly/patternfly-elements/commit/b691da07c4f3e150337698044369e64b9d2ad849) docs: Adjust example code block for typography classes
55
- [974ab6f](https://github.com/patternfly/patternfly-elements/commit/974ab6f1ab4047d4e94007d64a31e5a0cddf9b7a) fix: typos in package.json files
66
- [b18dd64](https://github.com/patternfly/patternfly-elements/commit/b18dd64da950b580b526ebe092b59eaadaf7d07e) fix: fix for re-renders when there is no selectedindex
7-
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: added resize observer for lining up progress bar
7+
- [f727065](https://github.com/patternfly/patternfly-elements/commit/f72706530754d9ea27779796d87e227edd0c238e) fix: added resize observer for lining up progress bar
8+
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: Pfe-Primary-Detail - Fixed issues from Safari, IE11, and the escape key didn't work as expected in compact layout
89

910
# 1.11.0 (2021-08-18)
1011

elements/pfe-primary-detail/src/pfe-primary-detail.js

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ class PfePrimaryDetail extends PFElement {
199199
this.removeEventListener("keydown", this._keyboardControls);
200200
}
201201

202+
/**
203+
* Adds active class to shadow DOM if component is active to avoid animation jank
204+
* @note For some reason, when using :host([active]) to transformX, entering an active state got a janky animation.
205+
* Using active class that lives in the shadow root does not ¯\_(ツ)_/¯
206+
*/
202207
_manageWrapperAttributes() {
203208
if (this.hasAttribute("active")) {
204209
this._wrapper.classList.add("active");
@@ -256,7 +261,8 @@ class PfePrimaryDetail extends PFElement {
256261
this._slots.detailsNav[index] = toggle;
257262

258263
if (createToggleButton) {
259-
detailNavElement.replaceWith(toggle);
264+
// Using replaceChild to avoid IE issues
265+
detailNavElement.parentElement.replaceChild(toggle, detailNavElement);
260266
}
261267
}
262268

@@ -492,7 +498,7 @@ class PfePrimaryDetail extends PFElement {
492498
const nextToggle = e.target;
493499

494500
// Detect if handleHideShow was called by an event listener or manually in code
495-
if (typeof e === "object" && Array.isArray(e.path)) {
501+
if (typeof e === "object" && e instanceof Event) {
496502
// If the user has interacted with the component remove the pristine attribute
497503
this._wrapper.removeAttribute("data-pristine");
498504
}
@@ -522,7 +528,7 @@ class PfePrimaryDetail extends PFElement {
522528
newHeading.innerText = nextToggle.innerText;
523529
newHeading.id = this._detailsWrapperHeading.id;
524530
// Replace old heading
525-
this._detailsWrapperHeading.replaceWith(newHeading);
531+
this._detailsWrapperHeading.parentElement.replaceChild(newHeading, this._detailsWrapperHeading);
526532
this._detailsWrapperHeading = newHeading;
527533

528534
// Make sure the aria-controls attribute is set to the details wrapper
@@ -654,14 +660,15 @@ class PfePrimaryDetail extends PFElement {
654660
*/
655661
_keyboardControls(event) {
656662
const currentElement = event.target;
657-
658-
if (!this._isToggle(currentElement)) {
659-
return;
660-
}
661-
662663
let newToggle;
663664

664665
switch (event.key) {
666+
case "Escape":
667+
// Only closing all at compact sizes since something should always be selected at non-compact
668+
if (this.getAttribute("breakpoint") === "compact") {
669+
this.closeAll();
670+
}
671+
break;
665672
// case "Tab":
666673
// Tab (Default tab behavior)
667674
/// When focus moves into the tab list, places focus on the active tab element
@@ -672,6 +679,9 @@ class PfePrimaryDetail extends PFElement {
672679
case "Up":
673680
case "ArrowLeft":
674681
case "Left":
682+
if (!this._isToggle(currentElement)) {
683+
return;
684+
}
675685
event.preventDefault(); // Prevent scrolling
676686
// Up Arrow/Left Arrow
677687
/// When tab has focus:
@@ -684,6 +694,9 @@ class PfePrimaryDetail extends PFElement {
684694
case "Down":
685695
case "ArrowRight":
686696
case "Right":
697+
if (!this._isToggle(currentElement)) {
698+
return;
699+
}
687700
event.preventDefault(); // Prevent scrolling
688701
// Down Arrow/Right Arrow
689702
/// When tab has focus:
@@ -695,6 +708,9 @@ class PfePrimaryDetail extends PFElement {
695708
break;
696709

697710
case "Home":
711+
if (!this._isToggle(currentElement)) {
712+
return;
713+
}
698714
event.preventDefault(); // Prevent scrolling
699715
// Home
700716
//// When a tab has focus, moves focus to the first tab
@@ -703,19 +719,16 @@ class PfePrimaryDetail extends PFElement {
703719
break;
704720

705721
case "End":
722+
if (!this._isToggle(currentElement)) {
723+
return;
724+
}
706725
event.preventDefault(); // Prevent scrolling
707726
// End
708727
/// When a tab has focus, moves focus to the last tab
709728

710729
newToggle = this._slots.detailsNav[this._slots.detailsNav.length - 1];
711730
break;
712731

713-
case "Escape":
714-
// Only closing all at compact sizes since something should always be selected at non-compact
715-
if (this.getAttribute("breakpoint") === "compact") {
716-
this.closeAll();
717-
}
718-
break;
719732
default:
720733
return;
721734
}

0 commit comments

Comments
 (0)