Dropdown doesn't close when item triggers modal and use close button - semantic-ui

I have created a Dropdown.Item that, when pressed triggers a modal. If I close the Modal by pressing the Close Icon of the modal, the modal disappears and the dropdown is still open behind it. If I close the modal by clicking outside the modal, both are closed. I would like the dropdown to be closed in both cases.
This is code I created in the semantic sandbox that recreates the issue
import React from 'react'
import { Dropdown, Modal, Button, Icon, Header } from 'semantic-ui-react'
const DropdownExampleDropdown = () => (
<Dropdown text='File'>
<Dropdown.Menu>
<ModalExampleCloseIcon />
<Dropdown.Item text='Open...' description='ctrl + o' />
</Dropdown.Menu>
</Dropdown>
)
const ModalExampleCloseIcon = () => (
<Modal trigger={<Dropdown.Item text='Details' />} closeIcon>
<Header icon='archive' content='Archive Old Messages' />
<Modal.Content>
<p>
Your inbox is getting full, would you like us to enable automatic archiving of old messages?
</p>
</Modal.Content>
<Modal.Actions>
<Button color='red'>
<Icon name='remove' /> No
</Button>
<Button color='green'>
<Icon name='checkmark' /> Yes
</Button>
</Modal.Actions>
</Modal>
)
export default DropdownExampleDropdown
If you click on the "File" dropdown and then on "Details", a modal will appear. Pressing on the X in the modal closes the modal, but the "Details" and "Open.." options of the dropdown is still visible. If you click the "Details" button and then click outside the modal, the modal disappears and the dropdown closes. You see the "File" dropdown as it originally appeared, which is what I would like to see in both cases.

Related

Why is my cursor pointer disabled on <button> after refresh?

I'm trying to build an Uniswap Clone with React & Tailwind CSS, and I have created a "Connect Wallet" button that triggers a Metamask popup to connect wallet.
Everything else seems to be working fine, but when I fully refresh the web application page, my cursor pointer becomes disabled when I hover over the "Connect Wallet" button.** Basically, my cursor stays at the default arrow pointer mode, doesn't change to cursor pointer, and I am unable to click the button.
Image of app in Chrome Browser
Interestingly enough, when I refresh the page and quickly place my mouse over the Connect Wallet button, I am briefly able to click the button and open the Metamask Pop-up as usual. But, when the page is fully refreshed, the cursor goes back to the normal/default arrow pointer, and I am unable to click the button.
Anybody have an idea of what might be causing this, and how I may be able to resolve it?
PS: I have tried to add "cursor-pointer" class to my button. I thought it would force the cursor to change to pointer on hover, but this didn't fix the problem.
Here's my React code block for the button:
const WalletButton = () => {
const [rendered, setRendered] = useState('');
const {ens} = useLookupAddress();
const {account, activateBrowserWallet, deactivate} = useEthers();
return (
<button
onClick={() => {
if (!account) {
activateBrowserWallet();
} else {
deactivate();
}
}}
className={styles.walletButton}
>
{rendered === "" && "Connect Wallet"}
{rendered !== "" && rendered}
</button>
);
};
export default WalletButton
Here are the tailwind CSS styles that are currently applied to the button:
// WalletButton
walletButton:
"bg-site-pink border-none outline-none px-6 py-2 font-poppins font-bold text-lg text-white rounded-3xl leading-[24px] hover:bg-pink-600 transition-all",

How do I make a material-ui select with a tooltip that doesn't make the select larger?

I have a material-ui select in react, built like so:
<TextField
fullWidth
select
id={'area'}
label={'Area'}
value={DCA.area ? DCA.area : ''}
variant={TEXT_FIELD_VARIANT_TYPE}
onChange={(evt) => handleValueChange(evt, 'area')}
>
{ Object.keys(dcaData[DCA.domain][DCA.category]).map(selectKey =>
<Tooltip key={"Area_MenuItem_Tooltip_" + selectKey} title={dcaData[DCA.domain][DCA.category][selectKey]} value={selectKey} >
<MenuItem key={"Area_MenuItem_Tooltip_" + selectKey} value={selectKey} >{selectKey}</MenuItem>
</Tooltip>
)}
</TextField>
This is functional.
The problem is there is an identical select next to it. That select does not have a tooltip. When you add the tooltip, it all works as expected... except when the select has been selected, the height of the textfield changes.
I have tried adding style={{padding:'0px'}} to the TextField, the Tooltop, and the MenuItem. When added to the Tooltip or the MenuItem, it helps (but doesn't entirely fix the problem) but then the 'drop down' popup menu is also without padding and doesn't match the style of the other selects.
Is there something I can do to add the tooltip but keep the 'collapsed' / selected TextField from changing it's size?

Alert modal from sidebar close(X) icon

I am using p-sidebar to display a component as a sidebar from another component. Now when the sidebar displays, it has a close(X) icon at the top right corner and clicking on it closes the sidebar. I want to display a alert modal when clicked in close(X) icon.
<p-sidebar [(visible)]="slideBarDisplay"
[style]="{'height':'75%','overflow':'scroll'}"
position="bottom">
<sidebar-component (add)="addNew($event)"
(cancelAdd)="slideBarDisplay = false"
*ngIf="slideBarDisplay">
</sidebar-component>
</p-sidebar>
and I have showClearModal = false; to display the modal in sidebar-component html.
So I want to call
showAlertDisplay() {
this.showClearModal = true
}
when clicked on close(X) button so it will make p-dialog visible.
Appreacite any help

Angular unfocus tab and set focus to different tab

I have a Material Tab component in Angular 2.
I want to have a button at the end of the tabs, that acts as a add tab button. Upon clicking on it a new tab is created before it.
I tried putting a button there, but couldn't find how to place it exactly next to the last tab.
So what I did is I added a tab that acts like a button. When this tab is clicked, a new tab is created.
However, when this tab is clicked, it gains focus. While I can change which tab is selected, the tab still has the focused UI (it is colored).
How can I make it lose it's focus completely?
P.S. If there is a way to add a regular button next to the last tab, without making it a tab, this would also be good.
Edit - Code:
This is how my tabs are setup:
<mat-tab-group (selectedTabChange)="selectedTab($event)">
<mat-tab>
<ng-template mat-tab-label>
Basic Details
</ng-template>
</mat-tab>
<mat-tab #categoryTab *ngFor="let table of mCase.Tables; let tableIndex = index" [attr.data-index]="tableIndex">
<mat-tab>
<mat-tab #addCategory>
<ng-template mat-tab-label>
<div color="white" class="center">Add category</div>
</ng-template>
</mat-tab>
</mat-tab-group>
Code behind:
public selectedTab(e) {
if (e.index == 1 + this.mCase.Tables.length) {
//Add new category
this.CreateTable();
this.selectedIndex = this.mCase.Tables.length;
}
Promise.resolve().then(() => this.selectedIndex = e.index);
}
You could try add the button like this:
<mat-tab-group>
<mat-tab>
<ng-template mat-tab-label>
Basic Details
</ng-template>
</mat-tab>
<mat-tab disabled>
<ng-template mat-tab-label>
<button mat-icon-button (click)="foo()">
<mat-icon>add_circle</mat-icon>
</button>
</ng-template>
</mat-tab>
</mat-tab-group>
Working example: https://stackblitz.com/edit/angular-zrklwg
By the way, if you are bothered by the button having disabled like styles, you can just override that with some custom CSS! :D
You can use .blur() on the event.currentTarget of the button which has been clicked. .blur() is the opposite of the .focus() method and will remove focus from an element.
In you question you said:
Upon clicking on it a new tab is created before it.
You didn't add any html, so I just went and created an example of how you can dynamically append buttons to the html via a data bound array.
this.buttons.splice(clickedButtonIndex, 0, {Name: "New Button"});
To learn about how this works, see this answer.
This is the crux of the component code that you can use to blur focus on the element.
addButton(clickedButtonIndex, event){
this.buttons.splice(clickedButtonIndex, 0, {Name: "New Button"});
event.currentTarget.blur();
}
Working Example: https://stackblitz.com/edit/angular-vslscm
In the example, I have set a red background in css to be applied to buttons when they are focused. You can see that when you click on a button, it momentarily will turn red before being toggled off again. Clicking the buttons will add a new button before the button which was clicked.

popover in the footer

I am using an icon in the footer using fragmentation. On press of the icon, it opens a popover. I want the popover above the footer but it is opening below it and no content is visible.
sapui5 <xml>
<footer>
<OverflowToolbar id="otbFooter">
<ToolbarSpacer/>
<OverflowToolbarButton text="Add" icon="sap-icon://add" press="popover" class="popover"/>
</OverflowToolbar>
</footer>
Set placement property of sap.m.Popover to Top.
<Popover title="{Name}" placement="Top">

Resources