-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ActionMenu position issue when container is scrollable (#3207)
- Loading branch information
Showing
7 changed files
with
77 additions
and
26 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/view-components': patch | ||
--- | ||
|
||
Fix ActionMenu position issue when container is scrollable |
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Waits for condition to return true. If it returns false initially, this function creates a | ||
// MutationObserver that calls body() whenever the contents of the component change. | ||
export const observeMutationsUntilConditionMet = (element: Element, condition: () => boolean, body: () => void) => { | ||
if (condition()) { | ||
body() | ||
} else { | ||
const mutationObserver = new MutationObserver(() => { | ||
if (condition()) { | ||
body() | ||
mutationObserver.disconnect() | ||
} | ||
}) | ||
|
||
mutationObserver.observe(element, {childList: true, subtree: true}) | ||
} | ||
} |
8 changes: 3 additions & 5 deletions
8
previews/primer/alpha/action_menu_preview/in_scroll_container.html.erb
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,11 +1,9 @@ | ||
<div style="height: 400px"></div> | ||
|
||
<div style="position: relative"> | ||
<div style="height: 1000px; overflow: auto"> | ||
<div style="height: 400px"></div> | ||
<%= render Primer::Alpha::ActionMenu.new(anchor_align: :end) do |c| %> | ||
<% c.with_show_button { "Edit" } %> | ||
<% c.with_item(tag: :button, type: "button", label: "Rename") %> | ||
<% c.with_item(tag: :button, type: "button", scheme: :danger, label: "Remove") %> | ||
<% end %> | ||
<div style="height: 1400px"></div> | ||
</div> | ||
|
||
<div style="height: 1400px"></div> |